axi/examples/paths.py

33 lines
859 B
Python
Raw Normal View History

2017-01-16 03:03:12 +00:00
import axi
import sys
def main():
filename = sys.argv[1]
2017-03-25 00:25:15 +00:00
print 'loading paths'
2018-02-19 22:12:10 +00:00
# d = axi.Drawing(axi.load_paths(filename))
d = axi.Drawing.load(filename)
print len(d.paths)
2018-01-29 18:44:44 +00:00
# print 'eliminating duplicate paths'
# d.paths = list(set([tuple(x) for x in d.paths]))
2018-02-19 22:12:10 +00:00
# print 'joining paths'
# d = d.join_paths(0.001)
# print len(d.paths)
2017-03-25 00:25:15 +00:00
print 'transforming paths'
2018-02-19 22:12:10 +00:00
# d = d.scale(1, -1)
2018-02-22 20:00:27 +00:00
# d = d.rotate(180)
2017-03-25 00:25:15 +00:00
d = d.rotate_and_scale_to_fit(12, 8.5, step=90)
print 'sorting paths'
2017-01-16 03:03:12 +00:00
d = d.sort_paths()
2017-03-25 00:25:15 +00:00
print 'joining paths'
2018-01-29 18:44:44 +00:00
d = d.join_paths(0.01)
2018-02-19 22:12:10 +00:00
print len(d.paths)
2017-03-25 00:25:15 +00:00
print 'simplifying paths'
2017-01-16 03:03:12 +00:00
d = d.simplify_paths(0.001)
2017-03-25 00:25:15 +00:00
print 'rendering paths'
d.render(line_width=0.25/25.4).write_to_png('out.png')
2018-02-19 22:12:10 +00:00
d.dump('out.axi')
2018-01-29 18:44:44 +00:00
# axi.draw(d)
2017-01-16 03:03:12 +00:00
if __name__ == '__main__':
main()