create py3k branch
[PyX.git] / test / functional / test_graph3dloop.py
bloba6f2b03d9ecb41970c43cc48b8bf8930ffa3ec04
1 #!/usr/bin/env python
2 import sys; sys.path[:0] = ["../.."]
4 from pyx import *
6 p = lambda phi: graph.graphxyz.central(10, phi, 10-phi/18.0)
7 # p = lambda phi: graph.graphxyz.parallel(phi, 10/18.0)
9 d = document.document()
10 phi = 0.123
11 while phi < 360:
12 c = canvas.canvas()
13 g = c.insert(graph.graphxyz(10.5, 10, size=6, projector=p(phi),
14 x=graph.axis.lin(painter=graph.axis.painter.regular(gridattrs=[])),
15 y=graph.axis.lin(painter=graph.axis.painter.regular(gridattrs=[])),
16 z=graph.axis.lin(painter=graph.axis.painter.regular(gridattrs=[]))))
17 g.plot(graph.data.values(x=[0, 0, 0, 1], y=[0, 0, 1, 1], z=[0, 1, 0, 1], color=[0, 0.33, 0.67, 1]),
18 [graph.style.gridpos(index1=1, index2=2), graph.style.surface(gridcolor=color.gray(0.9))])
19 g.doplot()
20 g.text(2, 2, str(phi))
21 def vrect(vx1, vy1, vz1, vx2, vy2, vz2):
22 assert len([v1_v2 for v1_v2 in [(vx1, vx2), (vy1, vy2), (vz1, vz2)] if v1_v2[0] == v1_v2[1]]) == 1
23 if vz1 == vz2:
24 return path.path(path.moveto_pt(*g.vpos_pt(vx1, vy1, vz1)),
25 path.lineto_pt(*g.vpos_pt(vx1, vy2, vz1)),
26 path.lineto_pt(*g.vpos_pt(vx2, vy2, vz1)),
27 path.lineto_pt(*g.vpos_pt(vx2, vy1, vz1)),
28 path.closepath())
29 if vy1 == vy2:
30 return path.path(path.moveto_pt(*g.vpos_pt(vx1, vy1, vz1)),
31 path.lineto_pt(*g.vpos_pt(vx1, vy1, vz2)),
32 path.lineto_pt(*g.vpos_pt(vx2, vy1, vz2)),
33 path.lineto_pt(*g.vpos_pt(vx2, vy1, vz1)),
34 path.closepath())
35 if vx1 == vx2:
36 return path.path(path.moveto_pt(*g.vpos_pt(vx1, vy1, vz1)),
37 path.lineto_pt(*g.vpos_pt(vx1, vy2, vz1)),
38 path.lineto_pt(*g.vpos_pt(vx1, vy2, vz2)),
39 path.lineto_pt(*g.vpos_pt(vx1, vy1, vz2)),
40 path.closepath())
41 g.fill(vrect(0.4, 0.4, 0, 0.6, 0.6, 0), [g.pz0show and color.rgb.green or color.rgb.red])
42 g.fill(vrect(0.4, 0.4, 1, 0.6, 0.6, 1), [g.pz1show and color.rgb.green or color.rgb.red])
43 g.fill(vrect(0.4, 0, 0.4, 0.6, 0, 0.6), [g.py0show and color.rgb.green or color.rgb.red])
44 g.fill(vrect(0.4, 1, 0.4, 0.6, 1, 0.6), [g.py1show and color.rgb.green or color.rgb.red])
45 g.fill(vrect(0, 0.4, 0.4, 0, 0.6, 0.6), [g.px0show and color.rgb.green or color.rgb.red])
46 g.fill(vrect(1, 0.4, 0.4, 1, 0.6, 0.6), [g.px1show and color.rgb.green or color.rgb.red])
47 for axis in list(g.axes.values()):
48 g.stroke(axis.basepath(), [axis.hidden and color.rgb.red or color.rgb.green])
49 d.append(document.page(c))
50 phi += 5.67
52 d.writePSfile("test_graph3dloop")
53 d.writePDFfile("test_graph3dloop")