Generate and draw a fractal tree.

 Draw the trunk
 At the end of the trunk, split by some angle and draw two branches
 Repeat at the end of each branch until a sufficient level of branching is reached


Related tasks
 Pythagoras Tree


procedure main()
WOpen("size=800,600", "bg=black", "fg=white") | stop("*** cannot open window")
drawtree(400,500,-90,9)
WDone()
end
 
link WOpen
 
procedure drawtree(x,y,angle,depth)
if depth > 0 then {
   x2 := integer(x + cos(dtor(angle)) * depth * 10)
   y2 := integer(y + sin(dtor(angle)) * depth * 10)
   DrawLine(x,y,x2,y2)   
   drawtree(x2,y2,angle-20, depth-1)
   drawtree(x2,y2,angle+20, depth-1)
   }
return
end