fix svgfile aligments and add a test
[PyX.git] / design / beziertoline.py
blob621ffd45232a7eb8a49e4c3ed448fa0a33b21539
1 import sys, math
2 sys.path[:0] = [".."]
3 from pyx import *
4 from pyx.normpath import normpathparam
6 def mark(c, t, phi, x, y):
7 c.stroke(path.line(x-0.1, y, x+0.1, y))
8 c.stroke(path.line(x, y-0.1, x, y+0.1))
9 t = text.text(x, y, t, [text.halign.center, text.vshift.mathaxis])
10 t.circlealign(0.2, math.cos(phi*math.pi/180), math.sin(phi*math.pi/180))
11 c.insert(t)
12 c = canvas.canvas()
13 b = path.curve(0, 0, 0, 0.5, 0, 1, 4, 4).normpath()
14 l = path.line(*(b.atbegin() + b.atend()))
15 c.draw(l, [deco.shownormpath()])
16 c.draw(b, [deco.shownormpath()])
17 mark(c, "A", 180, 0, 0)
18 mark(c, "B", 180, 0, 0.5)
19 mark(c, "C", 180, 0, 1)
20 mark(c, "D", 0, 4, 4)
21 mark(c, "Y", -45, 2, 2)
22 mark(c, "X", 90, *b.at(normpathparam(b, 0, 0.5)))
23 mark(c, "X'", 135, *b.at(0.5*b.arclen()))
24 c.writeEPSfile("beziertoline")
25 c.writePDFfile("beziertoline")