add UnicodeEngine (MultiEngineText and axis texters returning MultiEngineText), texte...
[PyX.git] / test / functional / test_box.py
blobc11b896cdf94a9356d0acde52e14852b7d2fc56b
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 import math
5 from pyx import *
7 def drawexample(canvas, corner, linealign):
8 r = 1.5
9 if corner:
10 canvas.stroke(path.path(path.arc(5, 5, r, 0, 360)))
11 else:
12 canvas.stroke(path.path(path.arc(5.5, 5+math.sqrt(3)/6, r, 0, 360)))
13 phi = 0
14 while phi < 2 * math.pi + 1e-10:
15 if corner:
16 b = box.polygon(center=(5, 5), corners=((5, 5), (6, 5), (5.5, 5+math.sqrt(3)/2)))
17 else:
18 b = box.polygon(center=(5.5, 5+math.sqrt(3)/6), corners=((5, 5), (6, 5), (5.5, 5+math.sqrt(3)/2)))
19 if linealign:
20 b.linealign(r, math.cos(phi), math.sin(phi))
21 else:
22 b.circlealign(r, math.cos(phi), math.sin(phi))
23 if round(phi / math.pi * 2 * 100) % 100:
24 canvas.stroke(b.path(centerradius=0.05))
25 else:
26 canvas.stroke(b.path(centerradius=0.05), [color.rgb.red])
27 phi += math.pi / 50
29 c = canvas.canvas()
30 sc = c.insert(canvas.canvas([trafo.translate(0, 6)]))
31 drawexample(sc, 0, 0)
32 sc = c.insert(canvas.canvas([trafo.translate(6, 6)]))
33 drawexample(sc, 0, 1)
34 sc = c.insert(canvas.canvas([trafo.translate(0, 0)]))
35 drawexample(sc, 1, 0)
36 sc = c.insert(canvas.canvas([trafo.translate(6, 0)]))
37 drawexample(sc, 1, 1)
38 c.writeEPSfile("test_box", page_paperformat=document.paperformat.A4)
39 c.writePDFfile("test_box", page_paperformat=document.paperformat.A4)
40 c.writeSVGfile("test_box", page_paperformat=document.paperformat.A4)