File: pathstyles.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 (83 lines) | stat: -rwxr-xr-x 2,153 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/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 = 0.8

def drawstyle(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("style."+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


drawstyle("linecap.butt", showpath=1, default=1)
drawstyle("linecap.round", showpath=1)
drawstyle("linecap.square", showpath=1)

y += dy

drawstyle("linejoin.miter", showpath=1, default=1)
drawstyle("linejoin.round", showpath=1)
drawstyle("linejoin.bevel", showpath=1)

y += dy

drawstyle("linestyle.solid", default=1)
drawstyle("linestyle.dashed")
drawstyle("linestyle.dotted")
drawstyle("linestyle.dashdotted")

y += dy

drawstyle("linewidth.THIN")
drawstyle("linewidth.THIn")
drawstyle("linewidth.THin")
drawstyle("linewidth.Thin")
drawstyle("linewidth.thin")
drawstyle("linewidth.normal", default=1)
drawstyle("linewidth.thick")
drawstyle("linewidth.Thick")
drawstyle("linewidth.THick")
drawstyle("linewidth.THIck")
drawstyle("linewidth.THICk")
drawstyle("linewidth.THICK")

drawstyle("miterlimit.lessthan180deg", showpath=1)
drawstyle("miterlimit.lessthan90deg", showpath=1)
drawstyle("miterlimit.lessthan60deg", showpath=1)
drawstyle("miterlimit.lessthan45deg", showpath=1)
drawstyle("miterlimit.lessthan11deg", showpath=1, default=1)

y += dy

drawstyle("dash((1, 1, 2, 2, 3, 3), 0)")
drawstyle("dash((1, 1, 2, 2, 3, 3), 1)")
drawstyle("dash((1, 2, 3), 2)")
drawstyle("dash((1, 2, 3), 3)")
drawstyle("dash((1, 2, 3), 4)")
drawstyle("dash((1, 2, 3), rellengths=1)")


c.writeEPSfile("pathstyles")
c.writePDFfile("pathstyles")