source code

from math import sin, cos

lines = True

radius = WIDTH * 0.45

center = WIDTH * 0.5

theta_count = 5

k = 1

background(0.5)

nofill()

stroke(1)

strokewidth(1)

autoclosepath(False)

speed(60)

def draw():

global lines, radius, center, theta_count, k

if FRAME > 300:

k += 1

td = (300 / (FRAME % 300 + 1)) - 1

if lines:

beginpath()

start = False

for i in range(360 * theta_count):

theta = i / theta_count

# fill(sin(theta) + 1, 1, 0.4)

stroke(sin(theta) + 1, 1, 0.4)

t_r = 1

tr = t_r / k

t_total = t_r + tr + td

t_scale = radius / t_total

rr = t_r * t_scale

r = tr * t_scale

d = td * t_scale

x = (center + (rr+r)*cos(theta) - (d*cos(((rr+r)/r)*theta)))

y = (center + (rr+r)*sin(theta) - (d*sin(((rr+r)/r)*theta)))

if lines:

if not start:

moveto(x, y)

start = True

else:

lineto(x, y)

else:

rect(x, y, 1, 1)

if lines:

endpath()