File: intersect.py

package info (click to toggle)
pyx3 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: python: 27,656; makefile: 225; ansic: 130; sh: 17
file content (18 lines) | stat: -rw-r--r-- 436 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pyx import *

p1 = path.curve(0, 0, 1, 0, 1, 1, 2, 1)
p2 = path.circle(1, 0.5, 0.5)

(a1, a2), (b1, b2) = p1.intersect(p2)

x1, y1 = p1.at(a1)
x2, y2 = p1.at(a2)

c = canvas.canvas()
c.fill(path.circle(x1, y1, 0.1), [color.rgb.blue])
c.fill(path.circle(x2, y2, 0.1), [color.rgb.blue])
c.stroke(p1, [color.rgb.red])
c.stroke(p2, [color.rgb.green])
c.writeEPSfile("intersect")
c.writePDFfile("intersect")
c.writeSVGfile("intersect")