-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUseSvg.py
More file actions
32 lines (29 loc) · 1002 Bytes
/
UseSvg.py
File metadata and controls
32 lines (29 loc) · 1002 Bytes
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
# -----------------------------------------------------------------------------
#
# P A G E B O T E X A M P L E S
#
# Copyright (c) 2017 Thom Janssen <https://github.com/thomgb>
# www.pagebot.io
# Licensed under MIT conditions
#
# Supporting DrawBot, www.drawbot.com
# Supporting Flat, xxyxyz.org/flat
# -----------------------------------------------------------------------------
#
# UseSvg.py
#
import os
from pagebot.elements import *
from pagebot.document import Document
from pagebot.contexts.svgcontext import SvgContext
from pagebot.toolbox.color import color
context = SvgContext()
EXPORT_PATH = '_export/useSvg.svg'
doc = Document(autoPages=1, context=context)
page = doc[1]
newRect(x=100, y=200, w=300, h=400, fill=color(1, 0, 0), parent=page)
bs = context.newString('ABCDEF', style=dict(fontSize=100))
print(bs.__class__.__name__)
tb = newText(bs, x=100, y=400, fill=color(1, 0, 1), parent=page, )
doc.export(EXPORT_PATH)
os.system('open %s' % EXPORT_PATH)