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
			
							Duffings
- dE.niz
 - Posts: 17
 - Joined: Tue Jan 27, 2015 10:35 am
 - My devices: Ipad 2 / iphone 4s / macbook / imac .
 - Location: Belgium
 - Flag: 

 
Re: Duffings
Amazing !!!
dE.niz
			
			
									
									
						dE.niz
- Mr. Kibernetik
 - Site Admin
 - Posts: 4794
 - Joined: Mon Nov 19, 2012 10:16 pm
 - My devices: iPhone, iPad, MacBook
 - Location: Russia
 - Flag: 

 
Re: Duffings
Very interesting!
I made a modification: added color, changed speed, adapted for any screen:

			
			
									
									
						I made a modification: added color, changed speed, adapted for any screen:
Code: Select all
rem Duffings Oscillator by DrChip
rem color by Mr.K
graphics
refresh off
pi=3.141592653589793
twopi=2.0*pi
x=1.0
y=0.0
t=0.0
a=0.3
k1=0
centx=screen_width()/2
centy=screen_height()/2
maxk=min(centx,centy)/50
cd=0.005
cdr=-cd!cdg=cd!cdb=-cd
cr=2!cg=0!cb=0
do
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
cr+=cdr!if cr<=-1 or cr>=2 then cdr=-cdr
cg+=cdg!if cg<=-1 or cg>=2 then cdg=-cdg
cb+=cdb!if cb<=-1 or cb>=2 then cdb=-cdb
gosub drawball 
until forever
'draws a shiny ball
drawball: 
xd=x
yd=y
i1=centx/2*x+centx
j1=-centy/4*y+centy
for k=maxk to 1 step -1
s=0.09*(maxk-k)
c=(maxk-k)/maxk
fill color c*cr,c*cg,c*cb
fill circle i1+s,j1+s size k
next k
refresh
return