Star Vortex.bas


' Star Vortex.bas SmallBASIC 0.12.9 [B+=MGA] 2017-04-19
' Inspired by Andy Amaya's recent Neon Vortex at SdlBasic

' ++++++++++++ Instructions ! +++++++++++++
' Press Spacebar to change Plasma Coloring Setting
' Press Number keys 3 to 9 for that many pointed stars
'+++++++++++++++++++++++++++++++++++++++++++++++++++++

const cx = xmax/2
const cy = ymax/2

func
rand(n1, n2)
local l
if n1 > n2 then l.hi = n1 : l.lo = n2 else l.hi = n2 : l.lo = n1
rand = (rnd * (l.hi - l.lo + 1)) \ 1 + l.lo
end


func
starArr(x, y, rInner, rOuter, nPoints, angleOffset, fillTF)
' x, y are same as for circle,
' rInner is center circle radius
' rOuter is the outer most point of star
' nPoints is the number of points,
' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
' this is to allow us to spin the polygon of n sides
' TFfill filled True or False (1 or 0)
local p_angle, rad_angle_offset, x1, y1, i, arr
dim arr()
p_angle = rad(360 / nPoints) : rad_angle_offset = rad(angleOffset - 90)
x1 = x + rOuter * cos(rad_angle_offset)
y1 = y + rOuter * sin(rad_angle_offset)
arr << x1 : arr << y1
for i = 0 to nPoints - 1
x1 = x + rInner * cos(i * p_angle + rad_angle_offset + .5 * p_angle)
y1 = y + rInner * sin(i * p_angle + rad_angle_offset + .5 * p_angle)
arr << x1 : arr << y1
x1 = x + rOuter * cos((i + 1) * p_angle + rad_angle_offset)
y1 = y + rOuter * sin((i + 1) * p_angle + rad_angle_offset)
arr << x1 : arr << y1
next
if fillTF then drawpoly arr filled else drawpoly arr
starArr = arr
end

sub
resetPlasma() 'all globals
plasmaR = rnd ^ 2 : plasmaG = rnd ^ 2 : plasmaB = rnd ^ 2 : plasmaN = 0
end

sub
setPlasma() 'all globals
plasmaN += .37
cc = rgb(127+99*sin(plasmaR*plasmaN),127+99*sin(plasmaG*plasmaN),127+99*sin(plasmaB*plasmaN))
color cc
end

nP = 5 : ao = 0
resetPlasma
while 1
cls
k = inkey
if len(k) = 1 then
if k = " " then resetPlasma
if val(k) > 2 and val(k) <= 9 then nP = val(k)
fi
aoo = 0
for i = 200 to 10 step -.5 ' fine "toothed" setting, for setting more like saw blade try +- 5 or 10
setPlasma
s = StarArr( cx, cy, i, 3 * i, nP, i + ao, 1)
next
showpage
'delay 80
ao = ao - 3.5
wend

Very cool plasma effect. My eyes may never be the same again, but still, a cool effect... lol

J

ps: Just realized the Space Bar changes things... There goes the optic nerves as well... LOL