-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneratePattern.py
More file actions
33 lines (27 loc) · 938 Bytes
/
generatePattern.py
File metadata and controls
33 lines (27 loc) · 938 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
33
import os
from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
from generatePattern.gen_pattern import PatternMaker
patternType = ["circles", "acircles", "checkerboard"][2]
units = ["mm", "inches", "px", "m"][0]
columns = 11
rows = 10
square_size = 50
radius_rate = 5
radius = 5
page_width = 650
page_height = 600
outputPath = "./output/pattern"
outputDir = os.path.split(outputPath)[0]
if not os.path.exists(outputDir):
os.mkdir(outputDir)
svgOutputPath = outputPath + ".svg"
patternMaker = PatternMaker(columns, rows, svgOutputPath, units, square_size, radius_rate, radius, page_width, page_height)
{
"circles": patternMaker.make_circles_pattern,
"acircles": patternMaker.make_acircles_pattern,
"checkerboard": patternMaker.make_checkerboard_pattern
}[patternType]()
patternMaker.save()
imgOutPutPath = outputPath + ".png"
renderPM.drawToFile(svg2rlg(svgOutputPath), imgOutPutPath, fmt="PNG")