Olympic Rings

Swyddfa Developers

30 Oct 2020 1920 x 1080 1 revisions 28 sloc v0.11.0

..

import arlunio as ar
import arlunio.image as image
import arlunio.shape as shape

@ar.definition
def OlympicRings(width: int, height: int, *, spacing=0.5, pt=0.025):

    dy = spacing / 4
    dx = spacing / 2
    args = {"scale": 0.5, "r": spacing, "pt": pt}

    img = image.new((width, height), color="white")
    rings = [
        (shape.Circle(yc=dy, xc=-(2.2 * dx), **args), "#0ff"),
        (shape.Circle(yc=dy, **args), "#000"),
        (shape.Circle(yc=dy, xc=(2.2 * dx), **args), "#f00"),
        (shape.Circle(yc=-dy, xc=-(1.1 * dx), **args), "#ff0"),
        (shape.Circle(yc=-dy, xc=(1.1 * dx), **args), "#0f0")
    ]

    for ring, color in rings:
        img = image.fill(
            ring(width=width, height=height), foreground=color, image=img
        )

    return img

rings = OlympicRings()
img = rings(width=1920, height=1080)