~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to examples/drawing/metapost.py

  • Committer: Package Import Robot
  • Author(s): Stuart Prescott
  • Date: 2012-12-17 13:45:12 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: package-import@ubuntu.com-20121217134512-q85pr3q75fxii7mq
Tags: upstream-0.12.1
ImportĀ upstreamĀ versionĀ 0.12.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pyx import *
 
2
from pyx.metapost.path import beginknot, endknot, smoothknot, tensioncurve
 
3
 
 
4
p1, p2, p3, p4, p5 = (0, 0), (2, 1.33), (1.3, 3), (0.33, 2.33), (1, 1.67)
 
5
openpath = metapost.path.path([
 
6
    beginknot(*p1), tensioncurve(), smoothknot(*p2), tensioncurve(),
 
7
    smoothknot(*p3), tensioncurve(), smoothknot(*p4), tensioncurve(),
 
8
    endknot(*p5)])
 
9
closedpath = metapost.path.path([
 
10
    smoothknot(*p1), tensioncurve(), smoothknot(*p2), tensioncurve(),
 
11
    smoothknot(*p3), tensioncurve(), smoothknot(*p4), tensioncurve(),
 
12
    smoothknot(*p5), tensioncurve()])
 
13
c = canvas.canvas()
 
14
for p in [p1, p2, p3, p4, p5]:
 
15
    c.fill(path.circle(p[0], p[1], 0.05), [color.rgb.red])
 
16
    c.fill(path.circle(p[0], p[1], 0.05), [color.rgb.red, trafo.translate(2, 0)])
 
17
c.stroke(openpath)
 
18
c.stroke(closedpath, [trafo.translate(2, 0)])
 
19
 
 
20
c.writeEPSfile("metapost")
 
21
c.writePDFfile("metapost")