File: rects.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 (31 lines) | stat: -rw-r--r-- 1,110 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
from pyx import *

c = canvas.canvas()

rect1 = path.path(path.moveto(0, 0), path.lineto(1, 0),
                  path.moveto(1, 0), path.lineto(1, 1),
                  path.moveto(1, 1), path.lineto(0, 1),
                  path.moveto(0, 1), path.lineto(0, 0))

rect2 = path.path(path.moveto(0, 0), path.lineto(0, 1),
                  path.lineto(1, 1), path.lineto(1, 0),
                  path.lineto(0, 0))

rect3 = path.path(path.moveto(0, 0), path.lineto(0, 1),
                  path.lineto(1, 1), path.lineto(1, 0),
                  path.closepath())

c.stroke(rect1, [trafo.scale(2), style.linewidth.THICK])
c.text(1, -0.7, "(a)", [text.halign.center])

c.stroke(rect2, [trafo.scale(2).translated(4, 0), style.linewidth.THICK])
c.text(5, -0.7, "(b)", [text.halign.center])

c.stroke(rect3, [trafo.scale(2).translated(8, 0), style.linewidth.THICK])
c.text(9, -0.7, "(c)", [text.halign.center])

c.stroke(rect3, [trafo.scale(2).translated(12, 0), style.linewidth.THICK, deco.filled([color.grey(0.95)])])
c.text(13, -0.7, "(d)", [text.halign.center])

c.writeEPSfile("rects")
c.writePDFfile("rects")