!crank04a.bas animation
option arithmetic native
set window -400,400,-100,700
set axis color 1

set area color 8
set line width 2
let r=100
let L=500
set point style 4

for i=0 to 20
for z=0 to 2*pi step pi/18
set draw mode hidden
clear

let g=asin(r/L*sin(z))
let y=r+L+r*cos(z)-L*cos(g)
plot area:-20,y-20;20,y-20;20,y+20;-20,y+20;-20,y-20

plot points:r*sin(z),r*cos(z)+L
plot lines:r*sin(z),r*cos(z)+L;0,L

plot lines:r*sin(z),r*cos(z)+L;0,y
draw circle with scale(r)*shift(0,L)

set draw mode explicit
wait delay 0.04

next z
next i

END