File: arrows.py

package info (click to toggle)
pyx 0.10-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,316 kB
  • ctags: 2,779
  • sloc: python: 16,243; ansic: 131; makefile: 87; sh: 9
file content (51 lines) | stat: -rwxr-xr-x 1,263 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import sys
sys.path[:0] = [".."]
from pyx import *

text.set(mode="latex")
text.preamble(r"\renewcommand{\familydefault}{\ttdefault}")
c = canvas.canvas()

# positioning is quite ugly ... but it works at the moment
x = 0
y = 0
dx = 6
dy = -0.65
length = 1.2

def drawdeco(name, showpath=0, default=0):
    global x,y
    p = path.path(path.moveto(x + 0.1, y+0.1 ),
                       path.rlineto(length/2.0, 0.3),
                       path.rlineto(length/2.0, -0.3))
    c.stroke(p, [style.linewidth.THIck,  eval("deco."+name)])
    if showpath:
        c.stroke(p, [style.linewidth.Thin, color.gray.white])
    if default:
        name = name + r"\rm\quad (default)"
    c.text(x + 1.5, y + 0.15, name, [text.size.footnotesize])
    y += dy
    if y < -16:
        y = 0
        x += dx

drawdeco("earrow.Small")
drawdeco("earrow.small")
drawdeco("earrow.normal")
drawdeco("earrow.large")
drawdeco("earrow.Large")

y += dy

drawdeco("barrow.normal")

y += dy

drawdeco("earrow.Large([deco.filled([color.rgb.red]), style.linewidth.normal])")
drawdeco("earrow.normal(constriction=None)")
drawdeco("earrow.Large([style.linejoin.round])")
drawdeco("earrow.Large([deco.stroked.clear])")

c.writeEPSfile("arrows")
c.writePDFfile("arrows")