bump version number
[PyX.git] / manual / gradientname.py
blob294133ffb2fa0f0a52797fb7f6e1844a98262258
1 # WARNING: THIS IS REALLY OLD CODE. IT COULD PROBABLY BE DONE USING GRAPHX NOWADAYS.
2 # HOWEVER, WE DON'T CARE. JUST DON'T TAKE THIS CODE TOO SERIOUSLY.
4 import sys, imp, re
5 sys.path[:0] = [".."]
6 import pyx
7 from pyx import *
9 text.set(text.LatexRunner)
10 text.preamble(r"\renewcommand{\familydefault}{\ttdefault}")
12 c = canvas.canvas()
14 # data to be plotted
15 pf = graph.data.paramfunction("k", 0, 1, "color, xmin, xmax, ymin, ymax= k, k, 1, 0, 1")
17 # positioning is quite ugly ... but it works at the moment
18 y = 0
19 dy = -0.65
21 # we could use gradient.__dict__ to get the instances, but we
22 # would loose the ordering ... instead we just parse the file:
24 # see comment in colorname.py
26 p = re.compile("(?P<id>gradient\\.(?P<name>[a-z]+)) += [a-z]*gradient_[a-z]+\\(", re.IGNORECASE)
27 lines = imp.find_module("color", pyx.__path__)[0].readlines()
28 firstgraph = None
29 for line in lines: # we yet don't use a file iterator
30 m = p.match(line)
31 if m:
32 if firstgraph is None:
33 xaxis = graph.axis.lin(
34 parter=graph.axis.parter.lin(tickdists=["0.5","0.1"], labeldists=["1"]),
35 painter=graph.axis.painter.regular(
36 innerticklength=None,
37 outerticklength=graph.axis.painter.ticklength.normal),
38 linkpainter=graph.axis.painter.regular(innerticklength=None, labelattrs=None))
39 firstgraph = g = graph.graphxy(ypos=y, width=10, height=0.5, x2=xaxis, y=graph.axis.lin(parter=None))
40 else:
41 g = graph.graphxy(ypos=y, width=10, height=0.5, x2=graph.axis.linkedaxis(firstgraph.axes["x2"]), y=graph.axis.lin(parter=None))
42 g.plot(pf, [graph.style.rect(gradient=getattr(pyx.color.gradient, m.group("name")), keygraph=None)])
43 g.doplot()
44 g.finish()
45 c.insert(g)
46 c.text(10.2, y + 0.15, m.group("id"), [text.size.footnotesize])
47 y += dy
50 c.writePDFfile()