Old school plasma program
Posted: Fri Aug 08, 2014 6:46 pm
				
				Ported from the basic programming forum.
Runs rather slow on iPad3, even with refresh off
Somewhat better on iPhone 5s : 0,6 fps
			Runs rather slow on iPad3, even with refresh off
Somewhat better on iPhone 5s : 0,6 fps
Code: Select all
' sdl plasma example[size=150][size=200][/size][/size] on: https://gist.github.com/stevenlr/824019
' ported to CMLua by Cybermonkey 08/2014
' ported to OxygenBasic by Peter Wirbelauer  o7.o8.2o14
' ported to X11Basic by vsync o8.o8.2o14
' ported to Smart Basic on iPhone by Henko 8/8/2014
'
bw=320 ! bh=200 ! pi=3.14
graphics ! graphics clear 1,1,1
DIM c(256,3)
FOR x=0 TO 255
  r=255-((SIN(PI*2*x/255)+1)*127)
  c(x,0)=r/256
  c(x,1)=(SIN(PI*2*x/127)+1)/4
  c(x,2)=1-r/256
NEXT x
iter:
'  refresh off
  t=TIMER()
  FOR y=0 TO bh
    FOR x=0 TO bw
      a=COS(1.2*f)*100-y+100
      b=SIN(0.8*f)*160-x+160
      ind=((SIN(x/50+f+y/200)+SIN(SQR(b*b+a*a)/50))/2+1)*127
      draw pixel x,y COLOR c(ind,0),c(ind,1),c(ind,2)
    NEXT x
    ' VSYNC
  NEXT y
  fps=1000/(TIMER()-t)
  draw TEXT "fps= " & fps at 8,24
  f=f+0.2
' refresh
  goto iter
stop ! end