File: test_canvas.py

package info (click to toggle)
pyx3 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: python: 27,656; makefile: 225; ansic: 130; sh: 17
file content (27 lines) | stat: -rwxr-xr-x 765 bytes parent folder | download
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
#!/usr/bin/env python
import sys; sys.path[:0] = ["../.."]

from pyx import *

c = canvas.canvas()

p = ( path.line(10*unit.u_pt, 10*unit.u_pt, 40*unit.u_pt, 40*unit.u_pt) +
      path.line(10*unit.u_pt, 40*unit.u_pt, 40*unit.u_pt, 10*unit.u_pt) )

t1 = trafo.rotate(20)
t2 = trafo.translate(5,0)
t3 = trafo.mirror(10)

sc = canvas.canvas([t1, t2, t3])
c.insert(sc).stroke(p)

c.stroke(c.bbox().rect())

c.stroke(p.transformed(t1*t2*t3), [color.rgb.green, style.linestyle.dashed])

c.stroke(p, [color.rgb.red, style.linestyle.dotted, t3, t2, t1])

c.writeEPSfile("test_canvas", page_paperformat=document.paperformat.A4)
c.writePDFfile("test_canvas", page_paperformat=document.paperformat.A4)
c.writeSVGfile("test_canvas", page_paperformat=document.paperformat.A4)