setScreen(860, 500,false,"Fractal Tree")
DEG_TO_RAD=57.29578
function fractal (x,y,ang,len,n,ang2)
if n>8 then
tmp=colour(255*0.3,255*0.3,0)
else
tmp=colour(0,100,0)
end
drawLine(x,500-y,math.floor(math.cos (ang/DEG_TO_RAD)*len+x),500-math.floor( math.sin (ang/DEG_TO_RAD)*len+y),tmp)
if(n>0) then
fractal(math.cos (ang/DEG_TO_RAD)*len+x, math.sin (ang/DEG_TO_RAD)*len+y, ang + ang2,len-3, n - 1, ang2)
fractal(math.cos (ang/DEG_TO_RAD)*len+x, math.sin (ang/DEG_TO_RAD)*len+y, ang - ang2, len-3, n - 1, ang2)
end
end
while not done do
cls(BLACK)
mx,my,r,l=getMouseState()
fractal (860/2,0, 90, 50, 13,my/20)
update()
done=tryQuit()
end
endP() |