Show Menu
TOPICS×

s7vampy.create_path()

Create a new path.
Returns:
Path
Empty path instance
Build a path containing an unclosed triangle and a rectangle contour:
>>> from s7vampy import *
>>> p = create_path ()
>>> p.moveto(0, 100)
>>> p.rlineto(50, -100)
>>> p.rlineto(50, 100)
>>> p.moveto(200, 0)
>>> p.rlineto(100, 0)
>>> p.rlineto(0, 100)
>>> p.rlineto(-100, 0)
>>> p.close()

Iterate over the path:
>>> for c in p.contours:
>>>     print "Num segments:", len(c)
>>>     # Iterate over the segments in the contour
>>>     for seg in c:
>>>          print seg
Num segments: 2
[(0, 100), (50, 0)]
[(50, 0), (100, 100)]
Num segments: 4
[(200, 0), (300, 0)]
[(300, 0), (300, 100)]
[(300, 100), (200, 100)]
[(200, 100), (200, 0)]