From 3b35f93223dbc67c02b8bd4898a6ba0a9a3a36b3 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Sat, 10 Feb 2018 15:58:45 -0500 Subject: [PATCH] cleanup --- axi/device.py | 12 ++---------- axi/drawing.py | 16 ++++++++-------- examples/stars.py | 8 ++++---- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/axi/device.py b/axi/device.py index 6acd802..c99bcf0 100644 --- a/axi/device.py +++ b/axi/device.py @@ -25,17 +25,9 @@ PEN_DOWN_POSITION = 40 PEN_DOWN_SPEED = 150 PEN_DOWN_DELAY = 0 -# ACCELERATION = 8 -# MAX_VELOCITY = 6 -# CORNER_FACTOR = 0.005 - -ACCELERATION = 6 +ACCELERATION = 4 MAX_VELOCITY = 4 -CORNER_FACTOR = 0.0025 - -# ACCELERATION = 4 -# MAX_VELOCITY = 1 -# CORNER_FACTOR = 0.001 +CORNER_FACTOR = 0.005 VID_PID = '04D8:FD92' diff --git a/axi/drawing.py b/axi/drawing.py index 57b9483..291aa6f 100644 --- a/axi/drawing.py +++ b/axi/drawing.py @@ -177,7 +177,6 @@ class Drawing(object): scale = min(width / drawing.width, height / drawing.height) drawings.append((scale, angle, drawing)) scale, angle, drawing = max(drawings) - print angle return drawing.scale(scale, scale).center(width, height) def remove_paths_outside(self, width, height): @@ -193,11 +192,11 @@ class Drawing(object): paths.append(path) return Drawing(paths) - def render(self, scale=109, margin=1, line_width=0.5/25.4): + def render(self, scale=109, margin=1, line_width=0.5/25.4, show_bounds=True): if cairo is None: raise Exception('Drawing.render() requires cairo') - x1, y1, x2, y2 = self.bounds - # x1, y1, x2, y2 = (0, 0, 12, 8.5) + # x1, y1, x2, y2 = self.bounds + x1, y1, x2, y2 = (0, 0, 12, 8.5) w = x2 - x1 h = y2 - y1 margin *= scale @@ -212,10 +211,11 @@ class Drawing(object): dc.translate(-x1, -y1) dc.set_source_rgb(1, 1, 1) dc.paint() - # dc.set_source_rgb(0.5, 0.5, 0.5) - # dc.set_line_width(1 / scale) - # dc.rectangle(x1, y1, w, h) - # dc.stroke() + if show_bounds: + dc.set_source_rgb(0.5, 0.5, 0.5) + dc.set_line_width(1 / scale) + dc.rectangle(0, 0, 12, 8.5) + dc.stroke() dc.set_source_rgb(0, 0, 0) dc.set_line_width(line_width) for path in self.paths: diff --git a/examples/stars.py b/examples/stars.py index 71873b7..4e3e978 100644 --- a/examples/stars.py +++ b/examples/stars.py @@ -26,7 +26,7 @@ def star(x, y, r): return points[0::2] + points[1::2] def main(): - points = poisson_disc(0, 0, 11, 8.5, 0.4, 64) + points = poisson_disc(0, 0, 12, 8.5, 0.4, 64) index = Index(points) paths = [] for x1, y1 in points: @@ -36,10 +36,10 @@ def main(): d = math.hypot(x2 - x1, y2 - y1) paths.append(star(x1, y1, d / 2)) drawing = axi.Drawing(paths) - drawing = drawing.remove_paths_outside(11, 8.5) + drawing = drawing.remove_paths_outside(12, 8.5) drawing = drawing.sort_paths() - # im = drawing.render() - # im.write_to_png('out.png') + im = drawing.render() + im.write_to_png('out.png') axi.draw(drawing) if __name__ == '__main__':