{
/*This example shows how to fill a shape (in this case yet more spirograph curves, because we love them!!*/
removeall;: /*Warning: This can cause loss of data!*/
spirograph = function (o_plot, v_R, v_r, v_p, v_nRotations, v_thickness, s_color, s_fill)
{
t = vectorin(0, 0.05, 2 * pi * v_nRotations);:
x = (v_R + v_r) * cos(t) + v_p * cos((v_R + v_r) * t / v_r);:
y = (v_R + v_r)* sin(t) + v_p * sin((v_R + v_r) * t / v_r);:
addplot(o_plot, x, y, 0, v_thickness, s_color, 0, 0, s_fill):
}
p=createplot();:
spirograph(p, 52, -25, 36, 25, 4, "200,0,200", "80,200,120");:
showplot(p, 4, 4);:
removeall():
spirograph = function (v_R, v_r, v_p, v_start, v_step, v_stop, o_plot, v_lineSize, s_color, v_scale, v_n, s_fill)
{
t = vectorin(v_start, v_step, v_stop);:
x = (v_R + v_r) * cos(t) + v_p * cos((v_R + v_r) * t / v_r);:
y = (v_R + v_r) * sin(t) + v_p * sin((v_R + v_r) * t / v_r);:
addplot(o_plot, x * v_scale, y * v_scale, v_n, v_lineSize, s_color, 0, 0, s_fill);:
}
colors = strings(Green, Blue, DarkOrchid, Red, Chocolate, DarkSalmon, Goldenrod, Gold);:
fills = strings(Green, Blue, DarkOrchid, Red, Chocolate, DarkSalmon, Goldenrod, Gold);:
f = array(1.5, 1.25, 1.04, 0.86, 0.71, 0.58, 0.46, 0.37);:
p = createplot();:
ring = 0;:
repeat (8)
{
i = 0;:
repeat(4)
{
j = 0;:
repeat(8)
{
spirograph(60*itemat(f, ring), -15*itemat(f, ring) , 12*itemat(f, ring) , 2*pi*(i*0.250-.055) , 0.005,
2*pi*(i*0.250+.055), p, 2, stringat(colors, j), 3.0, j*(11.25)+0, stringat(fills, j));:
j = j + 1;:
}
i = i + 1;:
}
ring = ring + 1;:
}
showplot(p):
}