' 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
Last edited by Henko on Thu Jan 29, 2015 8:10 am, edited 1 time in total.
' sdl plasma example 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 r(256),g(256),b(256)
FOR x=0 TO 255
r(x)=(255-(SIN(PI*2*x/255)+1)*127)/256
g(x)=(SIN(PI*2*x/127)+1)/4
b(x)=1-r(x)
NEXT x
'refresh off
k3=sqr(35600)/50
iter:
timer reset
k1=COS(1.2*f)+1
k2=SIN(0.8*f)+1
FOR y=0 TO bh
FOR x=0 TO bw
ind=SIN(x/50+f+y/200+SIN(abs(k1-y/100+(k2-x/160)*1i)*k3))*63.5+127
draw pixel x,y COLOR r(ind),g(ind),b(ind)
NEXT x
' VSYNC
NEXT y
fps=1000/TIMER()
draw TEXT "fps= " & fps at 8,24
f+=0.2
'refresh
goto iter
Code:
' sdl plasma example 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=160 ! bh=100 ! pi=3.1415
graphics ! graphics clear 1,1,1
DIM r(256),g(256),b(256)
k3=sqr(35600)/50
draw font size 10
FOR x=0 TO 255
r(x)=(255-(SIN(PI*3*x/255)+1)*127)/256
g(x)=(SIN(PI*2*x/127)+1)/4
b(x)=1-r(x)
NEXT x
refresh off
iter:
timer reset
k1 = COS(1.2*f)+1
k2 = 1-k1
FOR y =0 TO bh step 5
FOR x =0 TO bw step 5
ind=SIN(x/50+f+y/200+SIN(abs(k1-y/100+(k2-x/160)*1i)*k3))*63.5+127
'draw pixel x,y COLOR r(ind),g(ind),b(ind)
fill COLOR r(ind),g(ind),b(ind)
fill rect x,y size 3
NEXT x
' VSYNC
NEXT y
fps = 1000/TIMER()
draw TEXT "fps= " & fps at 8,8
f += 0.15
refresh
goto iter