rem RGB Plasma Demo 
rem I was bored. Enjoy!
graphics
res=10  'Change this variable for quality
pi=3.1415
sw=screen_width()
sh=screen_height()
for a=1 to 2
b=0
for x=0 to sw step 20
for y=0 to sh step 20
 fill color b/255,(y/5)/255,((x+y)/12)/255
 fill rect x,y to x+19,y+19
 b=b+.05
next y
next x
'gray wall
fill color .25,.35,.45
fill rect 30,30 to sw-20,sh-20
'white outline
draw color 1,1,1
draw rect 28,28 to sw-20,sh-20
'title
draw color 1,1,1
draw text "RGB PLASMA DEMO" at 0,0
draw color .255,.155,.155
draw text "RGB PLASMA DEMO" at 1,1
draw color .155,.55,.55
draw text "RGB PLASMA DEMO" at 2,2
draw color .55,0,0
draw text "RGB PLASMA DEMO" at 3,3
next a
dim cs(7201)
for a=1 to 7200
 c=190+160*sin(a*pi/180)
 cs(a)=c
next a
loop:
refresh off
gosub plasma
refresh on
goto loop
'Draw The Plasma Display
plasma:
'Color Table Offsets
mm=mm+.01
q=30+30*sin(mm)
rs=int(360+350*sin(mm))
gs=int(720+710*cos(mm))
bs=int(1440+1430*cos(mm/3))
'Draw The Rectangles 
for x=40 to sw-40 step res
cn=cn+1
   w=q+q*sin(x*.01)
for y=49 to sh-40 step res
   fill color cs(y+rs+w)/255,cs(x+gs+w)/255,cs(bs+x+y+w)/255
   fill rect x,y to x+res,y+res
next y
next x
return
			
							RGB Plasma Demo
- 
				DrChip
 - Posts: 167
 - Joined: Wed Oct 22, 2014 3:26 pm
 - My devices: iPhone 4 to 6+,iPad mini to iPad air 2
 
RGB Plasma Demo
- Attachments
 - 
			
		
				
- image.jpg (195.31 KiB) Viewed 3731 times
 
 - 
			
		
				
- image.jpg (215.74 KiB) Viewed 3731 times
 
 
- 
				DrChip
 - Posts: 167
 - Joined: Wed Oct 22, 2014 3:26 pm
 - My devices: iPhone 4 to 6+,iPad mini to iPad air 2
 
Re: RGB Plasma Demo
Nice and fast! My code use to run fast on misoft basic. I'm porting most of my code here. SmartBasic is much faster, I just need to learn the syntax. Thanks for sharing!
			
			
									
									
						- 
				Henko
 - Posts: 835
 - Joined: Tue Apr 09, 2013 12:23 pm
 - My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
 - Flag: 

 
Re: RGB Plasma Demo
It becomes much faster when using rectangles in stead of pixels, as you did.
Must be blinding speed on your A8 processors
 
			
			
									
									
						Must be blinding speed on your A8 processors
Code: Select all
' https://gist.github.com/stevenlr/824019
' ported to Smart Basic on iPhone by Henko 8/8/2014
'
bw=25 ! bh=35 ! siz=20 ! pi=3.14
graphics ! graphics clear 1,1,1 ! refresh off
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
while 1
  FOR y=0 TO bh ! yy=siz*y
    FOR x=0 TO bw ! xx=siz*x
      a=COS(1.2*f)*100-yy+100
      b=SIN(0.8*f)*160-xx+160
      ind=((SIN(xx/50+f+yy/200)+SIN(SQR(b*b+a*a)/50))/2+1)*127
      fill color c(ind,0),c(ind,1),c(ind,2)
      fill rect xx,yy to xx+siz,yy+siz
    NEXT x
    ' VSYNC
  NEXT y
  f=f+0.2 ! refresh
  end while- 
				DrChip
 - Posts: 167
 - Joined: Wed Oct 22, 2014 3:26 pm
 - My devices: iPhone 4 to 6+,iPad mini to iPad air 2
 
Re: RGB Plasma Demo
Very cool! It's all about the area and rectangle size. At 1x1 on almost a full screen it's watchable! Cool!