From bf422c3ed859f9cc0c5965921085fa9928b8227e Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Sun, 4 Mar 2018 21:17:46 -0500 Subject: [PATCH] cleanup --- axi/drawing.py | 12 ++---------- axi/lindenmayer.py | 2 +- examples/lindenmayer.py | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/axi/drawing.py b/axi/drawing.py index 1a03e52..e3e2508 100644 --- a/axi/drawing.py +++ b/axi/drawing.py @@ -244,14 +244,11 @@ class Drawing(object): return Drawing(paths) def render(self, scale=109, margin=1, line_width=0.35/25.4, - bounds=None, show_bounds=True, - use_axi_bounds=False, show_axi_bounds=False): + bounds=None, show_bounds=True): if cairo is None: raise Exception('Drawing.render() requires cairo') bounds = bounds or self.bounds x1, y1, x2, y2 = bounds - if use_axi_bounds: - x1, y1, x2, y2 = (0, 0, 12, 8.5) w = x2 - x1 h = y2 - y1 margin *= scale @@ -266,15 +263,10 @@ class Drawing(object): dc.translate(-x1, -y1) dc.set_source_rgb(1, 1, 1) dc.paint() - if show_axi_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() if show_bounds: dc.set_source_rgb(0.5, 0.5, 0.5) dc.set_line_width(1 / scale) - dc.rectangle(*bounds) + dc.rectangle(x1, y1, w, h) dc.stroke() dc.set_source_rgb(0, 0, 0) dc.set_line_width(line_width) diff --git a/axi/lindenmayer.py b/axi/lindenmayer.py index 6c28a37..14d332d 100644 --- a/axi/lindenmayer.py +++ b/axi/lindenmayer.py @@ -13,7 +13,7 @@ class LSystem(object): def step(self, value): def func(match): rule = self.rules[match.group(0)] - if isinstance(rule, basestring): + if isinstance(rule, str): return rule return random.choice(rule) return self.pattern.sub(func, value) diff --git a/examples/lindenmayer.py b/examples/lindenmayer.py index e85034c..413cb40 100644 --- a/examples/lindenmayer.py +++ b/examples/lindenmayer.py @@ -14,7 +14,7 @@ def main(): d = d.rotate_and_scale_to_fit(12, 8.5, step=90) # d = d.sort_paths() # d = d.join_paths(0.015) - d.render().write_to_png('out.png') + d.render(bounds=axi.V3_BOUNDS).write_to_png('out.png') axi.draw(d) if __name__ == '__main__':