3 Based on cairo-demo/X11/cairo-demo.c
7 from gi
.repository
import Gtk
14 ctx
.rel_line_to(SIZE
, 2 * SIZE
)
15 ctx
.rel_line_to(-2 * SIZE
, 0)
21 ctx
.rel_line_to(2 * SIZE
, 0)
22 ctx
.rel_line_to(0, 2 * SIZE
)
23 ctx
.rel_line_to(-2 * SIZE
, 0)
29 ctx
.rel_line_to(2 * SIZE
, 2 * SIZE
)
30 ctx
.rel_line_to(-2 * SIZE
, 0)
31 ctx
.rel_line_to(2 * SIZE
, -2 * SIZE
)
37 ctx
.rel_curve_to(0, SIZE
, SIZE
, SIZE
, 2 * SIZE
, 0)
38 ctx
.rel_curve_to(SIZE
, -SIZE
, 2 * SIZE
, -SIZE
, 2 * SIZE
, 0)
39 ctx
.rel_curve_to(0, SIZE
, -SIZE
, SIZE
, - 2 * SIZE
, 0)
40 ctx
.rel_curve_to(-SIZE
, -SIZE
, - 2 * SIZE
, -SIZE
, - 2 * SIZE
, 0)
44 def draw_shapes(ctx
, x
, y
, fill
):
48 ctx
.translate(x
+ SIZE
, y
+ SIZE
)
56 ctx
.translate(3 * SIZE
, 0)
64 ctx
.translate(3 * SIZE
, 0)
72 ctx
.translate(3 * SIZE
, 0)
82 def fill_shapes(ctx
, x
, y
):
83 draw_shapes(ctx
, x
, y
, True)
86 def stroke_shapes(ctx
, x
, y
):
87 draw_shapes(ctx
, x
, y
, False)
91 ctx
.set_source_rgb(0, 0, 0)
93 ctx
.set_line_width(SIZE
/ 4)
94 ctx
.set_tolerance(0.1)
96 ctx
.set_line_join(cairo
.LINE_JOIN_ROUND
)
97 ctx
.set_dash([SIZE
/ 4.0, SIZE
/ 4.0], 0)
98 stroke_shapes(ctx
, 0, 0)
101 stroke_shapes(ctx
, 0, 3 * SIZE
)
103 ctx
.set_line_join(cairo
.LINE_JOIN_BEVEL
)
104 stroke_shapes(ctx
, 0, 6 * SIZE
)
106 ctx
.set_line_join(cairo
.LINE_JOIN_MITER
)
107 stroke_shapes(ctx
, 0, 9 * SIZE
)
109 fill_shapes(ctx
, 0, 12 * SIZE
)
111 ctx
.set_line_join(cairo
.LINE_JOIN_BEVEL
)
112 fill_shapes(ctx
, 0, 15 * SIZE
)
113 ctx
.set_source_rgb(1, 0, 0)
114 stroke_shapes(ctx
, 0, 15 * SIZE
)
119 win
.connect('destroy', lambda w
: Gtk
.main_quit())
120 win
.set_default_size(450, 550)
122 drawingarea
= Gtk
.DrawingArea()
124 drawingarea
.connect('draw', draw
)
129 if __name__
== '__main__':