add UnicodeEngine (MultiEngineText and axis texters returning MultiEngineText), texte...
[PyX.git] / test / functional / test_canvastrafoclip.py
blob12e34baad75a318cfdac3204ad89f04d229d8962
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 from pyx import *
6 trafo1 = trafo.rotate(45)
7 trafo2 = trafo.translate(1, 1)
8 clip = canvas.clip(path.rect(-1, -1, 2, 2))
9 content = canvas.canvas()
10 content.fill(path.rect(-2, -2, 2, 2), [color.rgb.red])
11 content.fill(path.rect(-2, 0, 2, 2), [color.rgb.green])
12 content.fill(path.rect(0, -2, 2, 2), [color.rgb.blue])
13 content.fill(path.rect(0, 0, 2, 2), [color.rgb.black])
15 def apply1(*args):
16 c = canvas.canvas(args)
17 c.insert(content)
18 return c
20 def apply2(*args):
21 c = sub = canvas.canvas()
22 for arg in reversed(args):
23 sub = sub.insert(canvas.canvas([arg]))
24 sub.insert(content)
25 return c
27 c = canvas.canvas()
29 c.insert(apply1(clip, trafo1, trafo2), [trafo.translate(0, 0)])
30 c.stroke(apply1(clip, trafo1, trafo2).bbox().rect(), [trafo.translate(0, 0)])
32 c.insert(apply2(clip, trafo1, trafo2), [trafo.translate(0, 5)])
33 c.stroke(apply2(clip, trafo1, trafo2).bbox().rect(), [trafo.translate(0, 5)])
35 c.insert(apply1(clip, trafo2, trafo1), [trafo.translate(5, 0)])
36 c.stroke(apply1(clip, trafo2, trafo1).bbox().rect(), [trafo.translate(5, 0)])
38 c.insert(apply2(clip, trafo2, trafo1), [trafo.translate(5, 5)])
39 c.stroke(apply2(clip, trafo2, trafo1).bbox().rect(), [trafo.translate(5, 5)])
41 c.insert(apply1(trafo1, clip, trafo2), [trafo.translate(10, 0)])
42 c.stroke(apply1(trafo1, clip, trafo2).bbox().rect(), [trafo.translate(10, 0)])
44 c.insert(apply2(trafo1, clip, trafo2), [trafo.translate(10, 5)])
45 c.stroke(apply2(trafo1, clip, trafo2).bbox().rect(), [trafo.translate(10, 5)])
47 c.insert(apply1(trafo2, clip, trafo1), [trafo.translate(15, 0)])
48 c.stroke(apply1(trafo2, clip, trafo1).bbox().rect(), [trafo.translate(15, 0)])
50 c.insert(apply2(trafo2, clip, trafo1), [trafo.translate(15, 5)])
51 c.stroke(apply2(trafo2, clip, trafo1).bbox().rect(), [trafo.translate(15, 5)])
53 c.insert(apply1(trafo1, trafo2, clip), [trafo.translate(20, 0)])
54 c.stroke(apply1(trafo1, trafo2, clip).bbox().rect(), [trafo.translate(20, 0)])
56 c.insert(apply2(trafo1, trafo2, clip), [trafo.translate(20, 5)])
57 c.stroke(apply2(trafo1, trafo2, clip).bbox().rect(), [trafo.translate(20, 5)])
59 c.insert(apply1(trafo2, trafo1, clip), [trafo.translate(25, 0)])
60 c.stroke(apply1(trafo2, trafo1, clip).bbox().rect(), [trafo.translate(25, 0)])
62 c.insert(apply2(trafo2, trafo1, clip), [trafo.translate(25, 5)])
63 c.stroke(apply2(trafo2, trafo1, clip).bbox().rect(), [trafo.translate(25, 5)])
65 c.writeEPSfile()
66 c.writePDFfile()
67 c.writeSVGfile()