2 import sys
; sys
.path
[:0] = ["../.."]
8 return cmd
.bbox().rect()
10 def drawpathwbbox(c
, p
):
11 c
.stroke(p
, [color
.rgb
.red
])
13 c
.stroke(np
, [color
.rgb
.green
, style
.linestyle
.dashed
])
17 for phi
in range(0,360,30):
18 drawpathwbbox(c
,path(arc(phi
*0.1, phi
*0.1, 1, 0, phi
)))
20 for phi
in range(0,360,30):
21 drawpathwbbox(c
,path(arc(phi
*0.1, 5+phi
*0.1, 1, phi
, 360)))
23 for phi
in range(0,360,30):
24 drawpathwbbox(c
,path(arc(phi
*0.1, 10+phi
*0.1, 1, phi
, phi
+30)))
26 for phi
in range(0,360,30):
27 drawpathwbbox(c
,path(arc(phi
*0.1, 15+phi
*0.1, 1, phi
, phi
+120)))
29 for phi
in range(0,360,30):
30 drawpathwbbox(c
,path(arc(phi
*0.1, 20+phi
*0.1, 1, phi
, phi
+210)))
32 for phi
in range(0,360,30):
33 drawpathwbbox(c
,path(arc(phi
*0.1, 25+phi
*0.1, 1, phi
, phi
+300)))
35 for phi
in range(0,360,30):
36 drawpathwbbox(c
,path(arc(phi
*0.1, 30+phi
*0.1, 1, phi
, phi
+390)))
39 for phi
in range(0,360,30):
40 drawpathwbbox(c
,path(moveto(20+phi
*0.1, phi
*0.09),
41 arc(20+phi
*0.1, phi
*0.1, 1, 0, phi
)))
43 for phi
in range(0,360,30):
44 drawpathwbbox(c
,path(moveto(20+phi
*0.1, 5+phi
*0.11),
45 arc(20+phi
*0.1, 5+phi
*0.1, 1, 0, phi
)))
47 for phi
in range(0,360,30):
48 drawpathwbbox(c
,path(moveto(20+phi
*0.1, 10+phi
*0.09),
49 arcn(20+phi
*0.1, 10+phi
*0.1, 1, 0, phi
)))
51 for phi
in range(0,360,30):
52 drawpathwbbox(c
,path(moveto(20+phi
*0.1, 15+phi
*0.11),
53 arcn(20+phi
*0.1, 15+phi
*0.1, 1, 0, phi
)))
55 for phi
in range(0,360,30):
56 drawpathwbbox(c
,path(moveto(50+phi
*0.1, phi
*0.09),
57 arc(50+phi
*0.1, phi
*0.1, 1, 0, phi
),
60 for phi
in range(0,360,30):
61 drawpathwbbox(c
,path(moveto(50+phi
*0.1, 5+phi
*0.11),
62 arc(50+phi
*0.1, 5+phi
*0.1, 1, 0, phi
),
65 for phi
in range(0,360,30):
66 drawpathwbbox(c
,path(moveto(50+phi
*0.1, 10+phi
*0.09),
67 arcn(50+phi
*0.1, 10+phi
*0.1, 1, 0, phi
),
70 for phi
in range(0,360,30):
71 drawpathwbbox(c
,path(moveto(50+phi
*0.1, 15+phi
*0.11),
72 arcn(50+phi
*0.1, 15+phi
*0.1, 1, 0, phi
),
76 def testcurvetobbox(c
):
77 drawpathwbbox(c
,path(moveto(10,60), curveto(12,66,14,65,12,69)))
81 sc
=c
.insert(canvas
.canvas([trafo
.translate(0,40).rotated(10)]))
83 p
=path(moveto(10,10), curveto(12,16,14,15,12,19)); drawpathwbbox(sc
,p
)
84 p
=path(moveto(5,17), curveto(6,18, 5,16, 7,15)); drawpathwbbox(sc
,p
)
88 clip
= canvas
.clip(rect(11,-9,10,5))
90 p1
= path(moveto(10,-10), curveto(12,-4, 14,-5, 12,-1));
91 p2
= path(moveto(12,-8), curveto(6,-2, 5,-4, 7,-5));
93 # just a simple test for clipping
94 sc
= c
.insert(canvas
.canvas([clip
]))
98 # more complicated operations
100 # 1. transformation followed by clipping:
101 # in this case, the clipping path will be evaluated in the
102 # context of the already transformed canvas, so that the
103 # actually displayed portion of the path should be the same
104 sc
= c
.insert(canvas
.canvas([trafo
.translate(5,0), clip
]))
105 drawpathwbbox(sc
, p1
)
106 drawpathwbbox(sc
, p2
)
108 # 2. clipping followed by transformation
109 # in this case, the clipping path will not be transformed, so
110 # that the display portionof the path should change
111 sc
= c
.insert(canvas
.canvas([clip
, trafo
.translate(1,1)]))
112 drawpathwbbox(sc
, p1
)
113 drawpathwbbox(sc
, p2
)
121 c
.writeEPSfile("test_bbox", page_paperformat
=document
.paperformat
.A4
, page_rotated
=1, page_fittosize
=1)
122 c
.writePDFfile("test_bbox")
123 c
.writeSVGfile("test_bbox")