~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to examples/path/sierpinski.py

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2006-11-26 14:04:53 UTC
  • mfrom: (2.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061126140453-1dq3cycpspmlik2t
Tags: 0.9-3
* New maintainer. Thank you for more than three years of
  maintenance,  Graham! Closes: #400087
* Don't hard-code python 2.3 in manual/Makefile.
  Thanks to Matthias Klose for the bug report and patch.
  Closes: #392634
* Remove obsolete dh_python call from debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Sierpinski triangle
2
 
# contributed by Gerhard Schmid
3
 
 
4
 
from math import sqrt
5
 
from pyx import *
6
 
 
7
 
# triangle geometry
8
 
l = 10
9
 
h = 0.5 * sqrt(3) * l
10
 
 
11
 
# base triangle path
12
 
p = path.path(path.moveto(0, 0),
13
 
              path.lineto(l, 0),
14
 
              path.lineto(0.5 * l, h),
15
 
              path.closepath())
16
 
 
17
 
for i in range(6):
18
 
    # path is scaled down ...
19
 
    p = p.transformed(trafo.scale(0.5))
20
 
    # ... and three times plotted (translated accordingly)
21
 
    p += ( p.transformed(trafo.translate(0.5 * l, 0)) +
22
 
           p.transformed(trafo.translate(0.25 * l, 0.5 * h)) )
23
 
 
24
 
c = canvas.canvas()
25
 
c.stroke(p, [style.linewidth.Thin])
26
 
c.writeEPSfile("sierpinski", paperformat="a4")
27