24 lines
1 KiB
Text
24 lines
1 KiB
Text
-V
|
||
Width = 1000
|
||
Height = 1000
|
||
TrunkLength = 400
|
||
ScaleFactor = 0.6
|
||
StartingAngle = 1.5 * math:pi
|
||
DeltaAngle = 0.2 * math:pi
|
||
|
||
F drawTree(outfile, Float x, Float y; len, theta) -> N
|
||
I len >= 1
|
||
V x2 = x + len * cos(theta)
|
||
V y2 = y + len * sin(theta)
|
||
outfile.write("<line x1='#.6' y1='#.6' x2='#.6' y2='#.6' style='stroke:white;stroke-width:1'/>\n".format(x, y, x2, y2))
|
||
drawTree(outfile, x2, y2, len * ScaleFactor, theta + DeltaAngle)
|
||
drawTree(outfile, x2, y2, len * ScaleFactor, theta - DeltaAngle)
|
||
|
||
V outsvg = File(‘tree.svg’, WRITE)
|
||
outsvg.write(|‘<?xml version='1.0' encoding='utf-8' standalone='no'?>
|
||
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
|
||
<svg width='100%%' height='100%%' version='1.1' xmlns='http://www.w3.org/2000/svg'>
|
||
<rect width="100%" height="100%" fill="black"/>
|
||
’)
|
||
drawTree(outsvg, 0.5 * Width, Height, TrunkLength, StartingAngle)
|
||
outsvg.write("</svg>\n")
|