Ghost

Swyddfa Developers

30 Oct 2020 1056 x 1056 1 revisions 24 sloc v0.11.0

..

import arlunio as ar
import arlunio.image as image
import arlunio.mask as mask
import arlunio.math as math
import arlunio.shape as shape

import numpy as np

@ar.definition
def Ghost(x: math.X, y: math.Y) -> mask.Mask:
    head = shape.Circle(yc=0.5, r=0.7)
    eyes = shape.Circle(xc=0.2, yc=0.6, r=0.3)

    body = mask.all_(
        y < 0.5,
        np.abs(x) < 0.49,
        0.1 * np.cos(5 * np.pi * x) - 0.3 < y
    )

    return (head(x=x, y=y) - eyes(x=np.abs(x), y=y)) + body

ghost = mask.Pixelize(defn=Ghost(y0=-0.3), scale=32)
img = image.fill(
    ghost(width=1080, height=1080), foreground="#f00", background="white"
)