nes updates
This commit is contained in:
parent
3c6fa0863b
commit
456c3dd712
|
@ -192,13 +192,14 @@ class Drawing(object):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
return Drawing(paths)
|
return Drawing(paths)
|
||||||
|
|
||||||
def render(self, scale=109, margin=30, line_width=0.5/25.4):
|
def render(self, scale=109, margin=1, line_width=0.5/25.4):
|
||||||
if cairo is None:
|
if cairo is None:
|
||||||
raise Exception('Drawing.render() requires cairo')
|
raise Exception('Drawing.render() requires cairo')
|
||||||
# x1, y1, x2, y2 = self.bounds
|
x1, y1, x2, y2 = self.bounds
|
||||||
x1, y1, x2, y2 = (0, 0, 12, 8.5)
|
# x1, y1, x2, y2 = (0, 0, 12, 8.5)
|
||||||
w = x2 - x1
|
w = x2 - x1
|
||||||
h = y2 - y1
|
h = y2 - y1
|
||||||
|
margin *= scale
|
||||||
width = int(scale * w + margin * 2)
|
width = int(scale * w + margin * 2)
|
||||||
height = int(scale * h + margin * 2)
|
height = int(scale * h + margin * 2)
|
||||||
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
|
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height)
|
||||||
|
@ -210,10 +211,10 @@ class Drawing(object):
|
||||||
dc.translate(-x1, -y1)
|
dc.translate(-x1, -y1)
|
||||||
dc.set_source_rgb(1, 1, 1)
|
dc.set_source_rgb(1, 1, 1)
|
||||||
dc.paint()
|
dc.paint()
|
||||||
dc.set_source_rgb(0.5, 0.5, 0.5)
|
# dc.set_source_rgb(0.5, 0.5, 0.5)
|
||||||
dc.set_line_width(1 / scale)
|
# dc.set_line_width(1 / scale)
|
||||||
dc.rectangle(x1, y1, w, h)
|
# dc.rectangle(x1, y1, w, h)
|
||||||
dc.stroke()
|
# dc.stroke()
|
||||||
dc.set_source_rgb(0, 0, 0)
|
dc.set_source_rgb(0, 0, 0)
|
||||||
dc.set_line_width(line_width)
|
dc.set_line_width(line_width)
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
|
|
|
@ -91,9 +91,10 @@ def main():
|
||||||
|
|
||||||
print d.bounds
|
print d.bounds
|
||||||
|
|
||||||
d.render(scale=109 * 1, line_width=0.3/25.4).write_to_png('nes/%d.png' % NUMBER)
|
|
||||||
d.dump_svg('nes/%d.svg' % NUMBER)
|
|
||||||
d.dump('nes/%d.axi' % NUMBER)
|
d.dump('nes/%d.axi' % NUMBER)
|
||||||
|
rotated = d.rotate(90).center(8.5, 12)
|
||||||
|
rotated.render(scale=109 * 1, line_width=0.3/25.4).write_to_png('nes/%d.png' % NUMBER)
|
||||||
|
rotated.dump_svg('nes/%d.svg' % NUMBER)
|
||||||
# print sum(x.t for x in axi.Device().plan_drawing(d)) / 60
|
# print sum(x.t for x in axi.Device().plan_drawing(d)) / 60
|
||||||
# axi.draw(d)
|
# axi.draw(d)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue