const width = height = 1000.0 const trunklength = 400.0 const scalefactor = 0.6 const startingangle = 1.5 * pi const deltaangle = 0.2 * pi function tree(fh, x, y, len, theta) if len >= 1.0 x2 = x + len * cos(theta) y2 = y + len * sin(theta) write(fh, "\n") tree(fh, x2, y2, len * scalefactor, theta + deltaangle) tree(fh, x2, y2, len * scalefactor, theta - deltaangle) end end outsvg = open("tree.svg", "w") write(outsvg, """ \n""") tree(outsvg, 0.5 * width, height, trunklength, startingangle) write(outsvg, "\n") # view file tree.svg in browser