This commit is contained in:
Michael Fogleman 2017-03-24 20:25:15 -04:00
parent de178ad998
commit 3b0c2c1a5f
2 changed files with 15 additions and 7 deletions

View File

@ -118,11 +118,11 @@ class Drawing(object):
paths.append(path)
return Drawing(paths)
def render(self, scale=96, margin=30, line_width=0.5/25.4):
def render(self, scale=109, margin=30, line_width=0.5/25.4):
if cairo is None:
raise Exception('Drawing.render() requires cairo')
# x1, y1, x2, y2 = self.bounds
x1, y1, x2, y2 = (0, 0, 11, 8.5)
x1, y1, x2, y2 = (0, 0, 12, 8.5)
w = x2 - x1
h = y2 - y1
width = int(scale * w + margin * 2)

View File

@ -3,14 +3,22 @@ import sys
def main():
filename = sys.argv[1]
print 'loading paths'
d = axi.Drawing(axi.load_paths(filename))
d = d.scale(1, -1)
d = d.scale_to_fit(12, 8.5)
print 'eliminating duplicate paths'
d.paths = list(set([tuple(x) for x in d.paths]))
print 'transforming paths'
# d = d.scale(1, -1)
d = d.rotate_and_scale_to_fit(12, 8.5, step=90)
print 'sorting paths'
d = d.sort_paths()
d = d.join_paths(0.001)
print 'joining paths'
d = d.join_paths(0.02)
print 'simplifying paths'
d = d.simplify_paths(0.001)
d.render().write_to_png('out.png')
axi.draw(d)
print 'rendering paths'
d.render(line_width=0.25/25.4).write_to_png('out.png')
# axi.draw(d)
if __name__ == '__main__':
main()