# Fractal Sprirograph
#
f(a1,a2,a3,a4,w1,w2,w3,w4,t) = -sin(t)-a1*sin(w1*t)-a2*sin(w2*t)\
                               -a3*sin(w3*t)-a4*sin(w4*t)
g(a1,a2,a3,a4,w1,w2,w3,w4,t) = +cos(t)+a1*cos(w1*t)+a2*cos(w2*t)\
                               +a3*cos(w3*t)+a4*cos(w4*t)

set term pngc enh size 480,480
set out "spirograph.png"
set parametric
set trange [0:2*pi]
unset border
unset tics
unset key
set size square
set samples int(2*pi*1000)
a1 = 1/3.0; a2 = 1.0/3**2; a3 = 1.0/3**3; a4 = 1.0/3**4
w1 = -4; w2 = 16; w3 = -64; w4 = 256;
plot f(a1,a2,a3,a4,w1,w2,w3,w4,t),g(a1,a2,a3,a4,w1,w2,w3,w4,t) w dots

! display "spirograph.png"