1 # -*- coding: ISO-8859-1 -*-
3 # contributed by Gerhard Schmid and André Wobst
10 # base transformations for the left, center, and right part of the tree
11 ltrafo
= trafo
.rotate(65).scaled(0.4).translated(0, l
* 2.0 / 3.0)
12 ctrafo
= trafo
.rotate(-4).scaled(0.75).translated(0, l
)
13 rtrafo
= trafo
.mirror(90).rotated(-65).scaled(0.35).translated(0, l
)
16 "return transformations for a recursive tree of given depth"
19 subtree
= tree(depth
- 1)
20 r
.extend([t
*ltrafo
for t
in subtree
])
21 r
.extend([t
*ctrafo
for t
in subtree
])
22 r
.extend([t
*rtrafo
for t
in subtree
])
27 # apply the transformation to a "sub"-canvas and insert it into the "main" canvas
28 c
.insert(canvas
.canvas([t
])).stroke(path
.line(0, 0, 0, l
))
29 # note that there is a difference when only transforming the line as in:
30 # c.stroke(path.line(0, 0, 0, l), [t])
31 # The difference is, that the linewidth would not be scaled down.
32 c
.writeEPSfile("tree")
33 c
.writePDFfile("tree")