Target

Swyddfa Developers

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

Combining a few circles we're able to draw a target:

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

@ar.definition
def Target(width: int, height: int) -> image.Image:
    img = image.new((width, height), color="white")
    parts = [
        (shape.Circle(pt=0.02), "#000"),
        (shape.Circle(r=0.75, pt=0.12), "#f00"),
        (shape.Circle(r=0.6, pt=0.05), "#f00"),
        (shape.Circle(r=0.4), "#f00"),
    ]

    for part, color in parts:
        img = image.fill(
            part(width=width, height=height), foreground=color, image=img
        )

    return img

target = Target()
img = target(width=1920, height=1080)