Tree Swirl.bas

A mod of Psych Star Swirl


' tree swirl.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-27
' mod with trees
' Psychedelic Star Swirl.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-03

cx = xmax / 2 : cy = ymax / 2 : StartAngle = 0
clr = 1 : r = rnd : g = rnd : b = rnd

while 1
cls
Bang
showpage
delay 1
StartAngle = StartAngle - pi/72
wend

sub
Bang()
angle = StartAngle
size = 3 : radius = .1 : ds = .1
while radius < 400
x = cos(angle) * radius
y = sin(angle) * radius
chColor
branch cx + x, cy + y, deg(atan2((y-cy),(x-cx))-90), size, 1
angle = angle + 41.0
radius = radius + 2.0
size = size + ds
ds = ds + 0.0001
wend
end

sub
chColor()
clr = clr + 1
color rgb(30+20*sin(r*clr), 167+80*sin(g*clr), 30+20*sin(r*clr))
if clr > 10000 then r = rnd : g = rnd : b = rnd : clr = 0
end

sub
branch(x, y, angD, length, lev)
local x2, y2, dx, dy, bc, i
x2 = x + cos(rad(angD)) * length
y2 = y - sin(rad(angD)) * length
line x, y, x2, y2
if lev>6 or length<1 then exit sub
lev+=1
branch x2,y2,angD+10+30*rnd,.8*length+.2*rnd*length,lev
branch x2,y2,angD-10-30*rnd,.8*length+.2*rnd*length,lev
end