convert to new normpath creation scheme
[PyX/mjg.git] / test / functional / test_arrow.py
blobeac02bbcb4f62fc8c565b6103eb94e8c55cf5beb
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 import pyx
5 from pyx import *
6 from pyx.path import *
7 import math
9 def testarrow(c):
10 c.stroke(path(moveto(10,20),
11 curveto(12,16,14,15,12,19),
12 rcurveto(-3,2,3,3,-2,4)),
13 [deco.barrow.small, deco.earrow.normal])
15 c.stroke(path(arc(8,15,4,10,70)), [deco.barrow.small, deco.earrow.normal])
16 c.stroke(path(arc(8,15,3,10,70)), [deco.barrow.small, deco.earrow.normal])
17 c.stroke(path(arc(8,15,2,10,70)), [deco.barrow.small, deco.earrow.normal])
18 c.stroke(path(arc(8,15,1,10,70)), [deco.barrow.small, deco.earrow.normal])
19 c.stroke(path(arc(8,15,0.5,10,70)), [deco.barrow.small, deco.earrow.normal])
21 base = 2
23 c.stroke(path(moveto(5,10), rlineto(5,0)),
24 [deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=None),
25 deco.earrow.SMall])
26 c.stroke(path(moveto(5,10.5), rlineto(5,0)),
27 [deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=None),
28 deco.earrow.Small])
29 c.stroke(path(moveto(5,11), rlineto(5,0)),
30 [deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=None),
31 deco.earrow.small])
32 c.stroke(path(moveto(5,11.5), rlineto(5,0)),
33 [deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=None),
34 deco.earrow.normal])
35 c.stroke(path(moveto(5,12), rlineto(5,0)),
36 [deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=None),
37 deco.earrow.large])
38 c.stroke(path(moveto(5,12.5), rlineto(5,0)),
39 [deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=None),
40 deco.earrow.Large])
41 c.stroke(path(moveto(5,13), rlineto(5,0)),
42 [deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=None),
43 deco.earrow.LArge])
44 c.stroke(path(moveto(5,13.5), rlineto(5,0)),
45 [deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=None),
46 deco.earrow.LARge])
48 lt = style.linewidth.THick
50 c.stroke(path(moveto(11,10), rlineto(5,0)),
51 [lt,
52 deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=None),
53 deco.earrow.SMall])
54 c.stroke(path(moveto(11,10.5), rlineto(5,0)),
55 [lt,
56 deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=None),
57 deco.earrow.Small])
58 c.stroke(path(moveto(11,11), rlineto(5,0)),
59 [lt,
60 deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=None),
61 deco.earrow.small])
62 c.stroke(path(moveto(11,11.5), rlineto(5,0)),
63 [lt,
64 deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=None),
65 deco.earrow.normal])
66 c.stroke(path(moveto(11,12), rlineto(5,0)),
67 [lt,
68 deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=None),
69 deco.earrow.large])
70 c.stroke(path(moveto(11,12.5), rlineto(5,0)),
71 [lt,
72 deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=None),
73 deco.earrow.Large])
74 c.stroke(path(moveto(11,13), rlineto(5,0)),
75 [lt,
76 deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=None),
77 deco.earrow.LArge(attrs=[style.linestyle.dashed, color.rgb.green])])
78 c.stroke(path(moveto(11,13.5), rlineto(5,0)),
79 [lt,
80 deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=None),
81 deco.earrow.LARge(attrs=[color.rgb.red,
82 deco.stroked([style.linejoin.round]),
83 deco.filled([color.rgb.blue])])])
87 c=canvas.canvas()
88 testarrow(c)
89 c.writeEPSfile("test_arrow", paperformat="a4", rotated=0, fittosize=1)
90 c.writePDFfile("test_arrow", paperformat="a4")