File: compiled_path.py

package info (click to toggle)
python-enable 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,280 kB
  • ctags: 13,899
  • sloc: cpp: 48,447; python: 28,502; ansic: 9,004; makefile: 315; sh: 44
file content (25 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# CompiledPath should always be imported from the same backend as the
# GC you are using.  In this case, we are using the image GraphicsContext
# so we can save to disk when we're done, so we grab the CompiledPath
# from there as well.
from kiva.image import GraphicsContext, CompiledPath
from kiva.constants import STROKE

star_points = [(-20,-30),
               (0, 30),
               (20,-30),
               (-30,10),
               (30,10),
               (-20,-30)]

path = CompiledPath()
path.move_to(*star_points[0])
for pt in star_points[1:]:
    path.line_to(*pt)

locs = [(100,100), (100,300), (100,500), (200,100), (200,300), (200,500)]

gc = GraphicsContext((300,600))
gc.set_stroke_color((0,0,1,1))
gc.draw_path_at_points(locs, path, STROKE)
gc.save("compiled_path.png")