- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtext_spans.py
More file actions
Latest commit
37 lines (31 loc) · 1.02 KB
/
Copy pathtext_spans.py
File metadata and controls
37 lines (31 loc) · 1.02 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
importpixie
image=pixie.Image(200, 200)
image.fill(pixie.Color(1, 1, 1, 1))
typeface=pixie.read_typeface("examples/data/Ubuntu-Regular_1.ttf")
defmake_font(typeface, size, color):
font=typeface.new_font()
font.size=size
font.paint.color=color
returnfont
spans=pixie.SeqSpan()
spans.append(pixie.Span(
"verb [with object] ",
make_font(typeface, 12, pixie.Color(0.78125, 0.78125, 0.78125, 1))
))
spans.append(pixie.Span(
"strallow\n",
make_font(typeface, 36, pixie.Color(0, 0, 0, 1))
))
spans.append(pixie.Span(
"\nstral·low\n",
make_font(typeface, 13, pixie.Color(0, 0.5, 0.953125, 1))
))
spans.append(pixie.Span(
"\n1. free (something) from restrictive restrictions \"the regulations are intended to strallow changes in public policy\" ",
make_font(typeface, 14, pixie.Color(0.3125, 0.3125, 0.3125, 1))
))
image.arrangement_fill_text(
spans.typeset(bounds=pixie.Vector2(180, 180)),
transform=pixie.translate(10, 10)
)
image.write_file("examples/text_spans.png")