'Duffings Oscillator
open window 640,512
setrgb 0,0,0,0

pi=3.141592653589793

clear window

x=1.0
y=0.0
t=0.0
a=0.3
twopi=2.0*pi
k1=0

repeat
 k1=k1+1
 x1=x+y/twopi
 y1=y+(-(x*x*x)+x-0.25*y+a*cos(t))/twopi
 t=0.01*mod(k1,628)
 x=x1
 y=y1
 if (t>pi) then
  draw(x,y,255)
 else
  draw(x,y,128)
 fi
until (1=0)

'draws a shiny ball
sub draw(xd,yd,cl)
 local i1,j1,c,i,k

 k=7

 i1=150*x+320
 j1=-88*y+256

 for i=127 to 255 step 16
  c=0.09*(7-k)
  setrgb 1,c1,i,i
  fill circle i1+c,j1+c,k
  k=k-1
 next i
end sub

