File: align.py

package info (click to toggle)
pyscript 0.6.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,428 kB
  • ctags: 1,175
  • sloc: python: 10,146; makefile: 67
file content (44 lines) | stat: -rwxr-xr-x 1,025 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
#!/usr/bin/env pyscript
# $Id: align.py,v 1.4 2005/03/02 01:40:03 paultcochrane Exp $

"""
align.py - example of using the Align class.

Define some Rectangles and Circles and show how the Align class aligns them
in a horizontal line.
"""

# import the pyscript objects
from pyscript import *

# set the default units to use
defaults.units=UNITS['cm']

# define some objects to align
r1 = Rectangle(width=2, height=1, c=P(0,0))
r2 = Rectangle(width=1, height=2, c=P(2,1))
c1 = Circle(c=P(3,2))
c2 = Circle(r=2, c=P(6,3))

# group the objects together to save their original positions
orig = Group(r1, r2, c1, c2)

# define an Align object and add the rectangles and circles to it
a = Align(a1="e", a2="w", space=None, angle=90)
for o in orig:
	a.append(o.copy())

# record where they started in red
orig.apply(fg=Color('Red'))

# make the linewidth of the aligned objects thicker
a.apply(linewidth=2)

# render the objects and save to file
render(
    orig,
    a,
    file="align.eps",
    )

# vim: expandtab shiftwidth=4: