' 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
Here is sdlaBasic version:
'DynaTree Pulse.sdlbas 2016-06-22 translation of
' 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
const xmax = 720
const ymax = 720
const pi = acos(-1)
const rad = pi / 180
setdisplay(xmax, ymax, 32, 1)
setcaption("DynaTree Pulse")
autoback(-2)
sub branch(x, y, startr, angD, lngth, level, angleChange)
x2 = x + cos(rad *angD) * lngth : y2 = y - sin(rad * angD) * lngth
dx = (x2 - x) / lngth : dy = (y2 - y) / lngth
if level >= 9 or startr < 1 or lngth <= 1 then
ink( rgb(60 + rnd * 190, 0, 0) )
fillcircle( x, y, 5)
else
ink( rgb(10 * level + 128, 0, 3 * level + 64) )
for i = 0 to lngth
fillcircle(x + dx * i, y + dy * i, startr +1)
next
branch(x2, y2, startr - 1, angD + angleChange, .8 * lngth, level + 1, angleChange)
branch(x2, y2, startr - 1, angD - angleChange, .8 * lngth, level + 1, angleChange)
end if
end sub
angleChange = 30
direction = 5
maxAngleChange = 180 : minAngleChange = 0 : aOffset = 0
while key(27) = 0
ink( rgb(50, 100, 200) )
bar(0, 0, xmax, ymax)
branch( xmax / 2, ymax / 2, .01 * ymax, 0 + aOffset, ymax * .12, 0, angleChange)
branch( xmax / 2, ymax / 2, .01 * ymax, 90 + aOffset, ymax * .12, 0, angleChange)
branch( xmax / 2, ymax / 2, .01 * ymax, 180 + aOffset, ymax * .12, 0, angleChange)
branch( xmax / 2, ymax / 2, .01 * ymax, 270 + aOffset, ymax * .12, 0, angleChange)
screenswap
wait(10)
angleChange += direction
if angleChange >= maxAngleChange then
direction *= -1
angleChange = maxAngleChange - 2
if minAngleChange + 2 < maxAngleChange - 45 then
minAngleChange += 2
end if
elseif angleChange <= minAngleChange then
direction *= -1
angleChange = minAngleChange + 1
if maxAngleChange - 10 > minAngleChange + 45 then
maxAngleChange -= 10
end if
end if
aOffset +=1
wend