Skip to content

Instantly share code, notes, and snippets.

@iamgreaser
Created July 8, 2011 00:20
Show Gist options
  • Save iamgreaser/1070851 to your computer and use it in GitHub Desktop.
Save iamgreaser/1070851 to your computer and use it in GitHub Desktop.
freebasic port of cb plasma thing
function Distance(x1 as double,y1 as double,x2 as double,y2 as double) as double
Distance = sqr((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
end function
function Max(a as double,b as double) as double
if a > b then
Max = a
else
Max = b
end if
end function
function Min(a as double,b as double) as double
if a < b then
Min = a
else
Min = b
end if
end function
function Sinx(a as double) as double
Sinx = Sin(a*3.14159265358979/180.0)
end function
dim as integer sh,ksx,ksy,sw,x,y,cl,yy
dim as double r,g,b,c,a
sh=600
ksx=4
ksy=3
sw=sh/ksy*ksx
SCREENres sw,sh,32,1
'SCREEN sw,sh,0,2
Const S=16
alku:
a += 1
screenLock
For x=0 To sw Step S' Step 2
For y=0 To sh Step S
r=Sinx(x*2-y^1.01-a*5)+Sinx(-y+a)+Sinx(Distance(0,0,x,y)^1.1+a/7*5+Sinx(a)*70)
g=Sinx(Distance(x,y,Sinx(a/3*5)*200+200,Sinx(a)*150+150)^1.3/3+a*2*5)
'b=Sin(20*a+y/10*Sin(a)*20)
b=Sinx(x*2-y^1.01-a*5)+Sinx(-y+a)+Sinx(Distance(0,0,x,y)^1.1+a/7*5+Sinx(a)*70)+Sinx(Distance(x,y,Sinx(a/3*5)*200+200,Sinx(a/5*5)*150+150)^1.3/3+a*2*5)
c=Sinx(x*2-y^1.01-a*5)+Sinx(-y+a)+Sinx(Distance(0,0,x,y)^1.1+a/7*5+Sinx(a)*70)+Sinx(Distance(x,y,Sinx(a/3*5)*200+200,Sinx(a/5*5)*150+150)^1.3/3+a*2*5)
r=Max(0,Min(1,r))
g=Max(0,Min(1,g))
b=Max(0,Min(1,b))
c=(Sinx(C*90+a)+1)*32
cl = rgb(Min(255,Max(0,(r*2+(r+b)+b)*c)),Min(255,Max(0,(r+r*2+b)*c)),Min(255,Max(0,(r+b+b*2)*c)))
Line (x,y)-(x+S-1,y+S-1), cl, bf
Next y
Next x
screenUnlock
sleep 5
Goto alku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment