-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUseSvgRects.py
More file actions
43 lines (36 loc) · 1.08 KB
/
UseSvgRects.py
File metadata and controls
43 lines (36 loc) · 1.08 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
38
39
40
41
42
43
# -----------------------------------------------------------------------------
#
# 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 random import random
from pagebot.elements import *
from pagebot.document import Document
if 0:
from pagebot.contexts.svgcontext import SvgContext
context = SvgContext()
EXPORT_PATH = '_export/useSvg.svg'
else:
from pagebot import getContext
context = getContext()
EXPORT_PATH = '_export/useSvg.pdf'
doc = Document(autoPages=1, context=context)
page = doc[1]
column = 100
row = 30
gutter = 8
for x in range(0, 600, column):
for y in range(0, 800, row):
newRect(x=x, y=y, w=column-gutter, h=row-gutter, fill=color(random(), random(), random()), parent=page)
doc.export(EXPORT_PATH)
os.system('open %s' % EXPORT_PATH)