DynaTree Pulse.bas

Another nice way to waste time:


' DynaTree Pulse.bas SmallBASIC 0.12.6 [B+=MGA] 2016-06-22

' attempt to simulate something D did some time ago
' and combine with something Peter did some time ago
' with something I did some time ago

direction = 5 : angleChange = 30 : limit = 9
maxAngleChange = 180 : minAngleChange = 0 : aOffset = 0
while 1
color 0, rgb(50, 100, 200) : cls
branch xmax / 2, ymax / 2, .01 * ymax, 0 + aOffset, ymax * .1, 0
branch xmax / 2, ymax / 2, .01 * ymax, 90 + aOffset, ymax * .1, 0
branch xmax / 2, ymax / 2, .01 * ymax, 180 + aOffset, ymax * .1, 0
branch xmax / 2, ymax / 2, .01 * ymax, 270 + aOffset, ymax * .1, 0
showpage
delay 10
angleChange += direction
if angleChange >= maxAngleChange then
direction *= -1
angleChange = maxAngleChange - 2
if minAngleChange + 2 < maxAngleChange - 45 then minAngleChange += 2
elif angleChange <= minAngleChange
direction *= -1
angleChange = minAngleChange + 1
if maxAngleChange - 10 > minAngleChange + 45 then maxAngleChange -= 10
fi
aOffset ++
wend

sub
branch(x, y, startr, angD, length, level)
local x2, y2, dx, dy, bc, i
x2 = x + cos(rad(angD)) * length : y2 = y - sin(rad(angD)) * length
dx = (x2 - x) / length : dy = (y2 - y) / length
if level >= limit or startr <= 1 or length <= 2 then
bc = rgb(60 + rnd * 190, 0, 0)
circle x, y, 5, 1, bc filled
else
bc = rgb(10 * level + 128, 0, 3 * level + 64)
for i = 0 to length
circle x + dx * i, y + dy * i, startr, 1, bc filled
next
branch x2, y2, startr - 1, angD + angleChange, .8 * length, level + 1
branch x2, y2, startr - 1, angD - angleChange, .8 * length, level + 1
fi
end

Really? I did not know that... wink, wink....

You do not have time to read this.... hit that keyboard.... lol

J