#https://www.shadertoy.com/view/MlfGzs

pixels = W:1024 H:1024

x = from -1 to 1 W
y = from 1 to -1 H

p1x = 0.85*cos(0)*(0.6+0.4*cos(0))
p1y = 0.85*cos(1)*(0.6+0.4*cos(1))
t=0.0
d=length2(x-p1x, y-p1y)
d1 = d

[loop start:36
t = t+max(0.41*d1,0.03)
p2x = 0.85*cos(t)*(0.6+0.4*cos(t*7))
p2y = 0.85*cos(t + 1)*(0.6+0.4*cos(t*7 + 1))
d1 = length2(x-p2x, y-p2y)
pax = x - p1x
pay = y - p1y
bax = p2x - p1x
bay = p2y - p1y
k = clamp((pax*bax + pay*bay)/(bax*bax + bay*bay),0.0,1.0)
t = length2(pax-bax*k, pay-bay*k)
d = min(d,t)
cd = length2(p2x, p2y)
loop end]

r = 0
g = 0
b = cd*0.5
