Wheels within wheels:
'Spirograph wheels within wheels.bas SmallBASIC 0.12.9 (B+=MGA) 2017-07-02
rO = ymax/2 - 10 ' fit screen radius of big circle
Ox = xmax/2
Oy = ymax/2
pIndex = 0
dim mark(4)
dim px(), py()
m = 0 : mark(0) = 0
for ir = 5 to 2 step -1
rI = rO/ir ' smaller circle that travels inside edge of larger
OI = rO /rI ' rate inner circle spins compared to angle on outer circle
for a = 0 to 2 * pi step pi/360 'while the inner circle contacts outer at angle a
cls
circle Ox, Oy, rO, 1, 9
'the origin of inner circle at same angle
Ix = Ox + (rO - rI) * cos(a)
Iy = Oy + (rO - rI) * sin(a)
Ia = OI * a 'the angle of the inner points are OI * a on outer circle
'draw line from origin of inner circle to outer edge
color 12
wheel Ix, Iy, rI, -Ia
for i = 0 to pIndex-1
pset px(i), py(i), 15
next
showpage
delay 10
next
m++
mark(m) = pIndex - 1
next
delay 2000
for j = 0 to m-1
cls
for i = mark(j) to mark(j+1)-1
pset px(i), py(i), 15
next
? "Press any..."
showpage
pause
next
sub wheel(x,y,r,a)
local i, x1, y1, x2, y2, rI2, Ix2, Iy2, Ia2
circle x, y, r
for i = 1 to 12
x1 = x + r*cos(i*2*pi/12 + a)
y1 = y + r*sin(i*2*pi/12 + a)
line x, y, x1, y1
if i = 12 then
x2 = x + r/2*cos(i*2*pi/12 + a)
y2 = y + r/2*sin(i*2*pi/12 + a)
px << x2
py << y2
pIndex = pIndex + 1
fi
next
if r > 20 then
rI2 = r / ir
Ix2 = x + (r - rI2) * cos(a)
Iy2 = y + (r - rI2) * sin(a)
Ia2 = r / rI2 * a
wheel Ix2, Iy2, rI2, -Ia2
end if
end