added a new parser
[PyX/mjg.git] / examples / circles.py
blob4ac1d095f5ef9f973884001706bd277268e50960
1 from pyx import *
3 circ1 = path.normpath(path.circle(0, 0, 1)) # you don't really need normpath,
4 circ2 = path.normpath(path.circle(1, 1, 1)) # but its better to have it once
5 # for those operations
6 (circ1a, circ1b), (circ2a, circ2b) = circ1.intersect(circ2)
7 intersection = (circ1.split(circ1b, circ1a)[1]
8 << circ2.split(circ2a, circ2b)[1]
9 << path.closepath())
10 union = (circ1.split(circ1b, circ1a)[0]
11 << circ2.split(circ2a, circ2b)[0]
12 << path.closepath())
14 c = canvas.canvas()
15 c.fill(union, color.rgb.blue)
16 c.fill(intersection, color.rgb.red)
17 c.stroke(circ1)
18 c.stroke(circ2)
19 c.writetofile("circles")