Duffings
Posted: Tue Feb 10, 2015 1:43 am
rem Duffings Oscillator
rem iPhone 6 plus / iOS 8.2 b5
graphics
pi=3.141592653589793
graphics clear 0,0,0
x=1.0
y=0.0
t=0.0
a=0.3
twopi=2.0*pi
k1=0
do
k1=k1+1
x1=x+y/twopi
y1=y+(-(x*x*x)+x-0.25*y+a*cos(t))/twopi
t=0.01*(k1%628)
x=x1
y=y1
if t>pi then
cl=1
gosub drawball
else
cl=128/255
gosub drawball
end if
until 1=0
'draws a shiny ball
drawball:
xd=x
yd=y
c=cl
k=7
i1=150*x+screen_width()/2
j1=-88*y+screen_height()/2
for i=127 to 255 step 16
c=0.09*(7-k)
fill color c1,i/255,i/255
fill circle i1+c,j1+c size k
k=k-1
next i
return
rem iPhone 6 plus / iOS 8.2 b5
graphics
pi=3.141592653589793
graphics clear 0,0,0
x=1.0
y=0.0
t=0.0
a=0.3
twopi=2.0*pi
k1=0
do
k1=k1+1
x1=x+y/twopi
y1=y+(-(x*x*x)+x-0.25*y+a*cos(t))/twopi
t=0.01*(k1%628)
x=x1
y=y1
if t>pi then
cl=1
gosub drawball
else
cl=128/255
gosub drawball
end if
until 1=0
'draws a shiny ball
drawball:
xd=x
yd=y
c=cl
k=7
i1=150*x+screen_width()/2
j1=-88*y+screen_height()/2
for i=127 to 255 step 16
c=0.09*(7-k)
fill color c1,i/255,i/255
fill circle i1+c,j1+c size k
k=k-1
next i
return