Page 1 of 1

RGB Plasma Demo

Posted: Wed Jan 28, 2015 8:51 pm
by DrChip
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

Re: RGB Plasma Demo

Posted: Wed Jan 28, 2015 11:14 pm
by Dav
Cool!

- Dav

Re: RGB Plasma Demo

Posted: Thu Jan 29, 2015 8:01 am
by Henko
viewtopic.php?f=20&t=649

And another one in this forum (also mentioning the origin of the code)

Re: RGB Plasma Demo

Posted: Thu Jan 29, 2015 8:16 am
by DrChip
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!

Re: RGB Plasma Demo

Posted: Thu Jan 29, 2015 8:38 am
by Henko
It becomes much faster when using rectangles in stead of pixels, as you did.
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

Re: RGB Plasma Demo

Posted: Thu Jan 29, 2015 9:02 am
by DrChip
Very cool! It's all about the area and rectangle size. At 1x1 on almost a full screen it's watchable! Cool!