allow empty return value for realpolyroots
[PyX/mjg.git] / test / functional / test_arrow.py
blobf5c76e55e83242216da417b090fe4efb3e7d0196
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,
14 deco.arrow(pos=0.5),
15 deco.arrow(pos=0.7, reversed=1)])
17 c.stroke(path(arc(8,15,4,10,70)), [deco.barrow.small, deco.earrow.normal])
18 c.stroke(path(arc(8,15,3,10,70)), [deco.barrow.small, deco.earrow.normal])
19 c.stroke(path(arc(8,15,2,10,70)), [deco.barrow.small, deco.earrow.normal])
20 c.stroke(path(arc(8,15,1,10,70)), [deco.barrow.small, deco.earrow.normal])
21 c.stroke(path(arc(8,15,0.5,10,70)), [deco.barrow.small, deco.earrow.normal])
23 base = 2
25 c.stroke(path(moveto(5,10), rlineto(5,0)),
26 [#deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=1),
27 deco.earrow.SMall,
28 deco.text("start", arclenfrombegin=0, angle=90)])
29 c.stroke(path(moveto(5,10.5), rlineto(5,0)),
30 [deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=1),
31 deco.earrow.Small,
32 deco.text("start+1", arclenfrombegin=1, angle=90)])
33 c.stroke(path(moveto(5,11), rlineto(5,0)),
34 [deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=1),
35 deco.earrow.small,
36 deco.text("center", angle=90)])
37 c.stroke(path(moveto(5,11.5), rlineto(5,0)),
38 [deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=1),
39 deco.earrow.normal,
40 deco.text("end-1", arclenfromend=1, angle=90)])
41 c.stroke(path(moveto(5,12), rlineto(5,0)),
42 [deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=1),
43 deco.earrow.large,
44 deco.text("end", arclenfromend=0, angle=90)])
45 c.stroke(path(moveto(5,12.5), rlineto(5,0)),
46 [deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=1),
47 deco.earrow.Large])
48 c.stroke(path(moveto(5,13), rlineto(5,0)),
49 [deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=1),
50 deco.earrow.LArge])
51 c.stroke(path(moveto(5,13.5), rlineto(5,0)),
52 [deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=1),
53 deco.earrow.LARge])
55 lt = style.linewidth.THick
57 c.stroke(path(moveto(11,10), rlineto(5,0)),
58 [lt,
59 deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=1),
60 deco.earrow.SMall])
61 c.stroke(path(moveto(11,10.5), rlineto(5,0)),
62 [lt,
63 deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=1),
64 deco.earrow.Small])
65 c.stroke(path(moveto(11,11), rlineto(5,0)),
66 [lt,
67 deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=1),
68 deco.earrow.small])
69 c.stroke(path(moveto(11,11.5), rlineto(5,0)),
70 [lt,
71 deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=1),
72 deco.earrow.normal])
73 c.stroke(path(moveto(11,12), rlineto(5,0)),
74 [lt,
75 deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=1),
76 deco.earrow.large])
77 c.stroke(path(moveto(11,12.5), rlineto(5,0)),
78 [lt,
79 deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=1),
80 deco.earrow.Large(attrs=[deco.stroked([style.linestyle.dashed]), deco.filled.clear])])
81 c.stroke(path(moveto(11,13), rlineto(5,0)),
82 [lt,
83 deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=1),
84 deco.earrow.LArge(attrs=[style.linestyle.dashed, color.rgb.green])])
85 c.stroke(path(moveto(11,13.5), rlineto(5,0)),
86 [lt,
87 deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=1),
88 deco.earrow.LARge(attrs=[color.rgb.red,
89 deco.stroked([style.linejoin.round]),
90 deco.filled([color.rgb.blue])])])
93 c=canvas.canvas()
94 testarrow(c)
95 c.writeEPSfile("test_arrow", paperformat=document.paperformat.A4, rotated=0, fittosize=1)
96 c.writePDFfile("test_arrow", paperformat=document.paperformat.A4)