Debian Codegraph @

examples/cairo_snippets/snippets/text.py

raw symbols SCIP
1 from math import pi
2 import cairo
3
4
5 def draw(cr, width, height):
6 cr.scale(width, height)
7 cr.set_line_width(0.04)
8
9 cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL,
10 cairo.FONT_WEIGHT_BOLD)
11 cr.set_font_size(0.35)
12
13 cr.move_to(0.04, 0.53)
14 cr.show_text("Hello")
15
16 cr.move_to(0.27, 0.65)
17 cr.text_path("void")
18 cr.set_source_rgb(0.5, 0.5, 1)
19 cr.fill_preserve()
20 cr.set_source_rgb(0, 0, 0)
21 cr.set_line_width(0.01)
22 cr.stroke()
23
24 # draw helping lines
25 cr.set_source_rgba(1, 0.2, 0.2, 0.6)
26 cr.arc(0.04, 0.53, 0.02, 0, 2 * pi)
27 cr.arc(0.27, 0.65, 0.02, 0, 2 * pi)
28 cr.fill()