Atom

Swyddfa Developers

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

Playing around with the values and the coordinate inputs it's possible to draw something that looks like a diagram of an atom:

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

@ar.definition
def Atom(x: math.X, y: math.Y):
    img = None

    ellipses = [
        (shape.Ellipse(a=1.5, b=0.5, pt=0.005), x, y),
        (shape.Ellipse(a=1.5, b=0.5, r=1, pt=0.005), x + y, y - x),
        (shape.Ellipse(a=0.5, b=1.5, pt=0.005), x, y),
        (shape.Ellipse(a=1.5, b=0.5, r=1, pt=0.005), x - y, x + y),
        (shape.Ellipse(a=1, b=1, r=0.15), x, y)
    ]

    bg = "white"

    for ellipse, ex, ey in ellipses:
        img = image.fill(ellipse(x=ex, y=ey), image=img, background=bg)
        bg = None

    return img

atom = Atom()
img = atom(width=1920, height=1080)