diff options
-rw-r--r-- | gerber/render/cairo_backend.py | 2 | ||||
-rw-r--r-- | gerber/render/svgwrite_backend.py | 2 | ||||
-rw-r--r-- | gerber/rs274x.py | 23 | ||||
-rw-r--r-- | gerber/tests/test_rs274x.py | 4 |
4 files changed, 14 insertions, 17 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index f79dfbe..326f44e 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -83,7 +83,7 @@ class GerberCairoContext(GerberContext): radius = SCALE * arc.radius
angle1 = arc.start_angle
angle2 = arc.end_angle
- width = arc.width if arc.width != 0 else 0.001
+ width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001
self.ctx.set_source_rgba(*color, alpha=self.alpha)
self.ctx.set_line_width(width * SCALE)
self.ctx.set_line_cap(cairo.LINE_CAP_ROUND)
diff --git a/gerber/render/svgwrite_backend.py b/gerber/render/svgwrite_backend.py index ae7c377..a88abfe 100644 --- a/gerber/render/svgwrite_backend.py +++ b/gerber/render/svgwrite_backend.py @@ -81,7 +81,7 @@ class GerberSvgContext(GerberContext): start = tuple(map(mul, arc.start, self.scale)) end = tuple(map(mul, arc.end, self.scale)) radius = SCALE * arc.radius - width = arc.width if arc.width != 0 else 0.001 + width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001 arc_path = self.dwg.path(d='M %f, %f' % start, stroke=svg_color(color), stroke_width=SCALE * width) diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 2dee7cf..c5c89fb 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -88,22 +88,19 @@ class GerberFile(CamFile): @property def bounds(self): - xbounds = [0.0, 0.0] - ybounds = [0.0, 0.0] - for stmt in [stmt for stmt in self.statements - if isinstance(stmt, CoordStmt)]: + min_x = min_y = 1000000 + max_x = max_y = -1000000 + + for stmt in [stmt for stmt in self.statements if isinstance(stmt, CoordStmt)]: if stmt.x is not None: - if stmt.x < xbounds[0]: - xbounds[0] = stmt.x - elif stmt.x > xbounds[1]: - xbounds[1] = stmt.x + min_x = min(stmt.x, min_x) + max_x = max(stmt.x, max_x) + if stmt.y is not None: - if stmt.y < ybounds[0]: - ybounds[0] = stmt.y - elif stmt.y > ybounds[1]: - ybounds[1] = stmt.y - return (xbounds, ybounds) + min_y = min(stmt.y, min_y) + max_y = max(stmt.y, max_y) + return ((min_x, max_x), (min_y, max_y)) def write(self, filename, settings=None): """ Write data out to a gerber file diff --git a/gerber/tests/test_rs274x.py b/gerber/tests/test_rs274x.py index 5185fa1..a3d20ed 100644 --- a/gerber/tests/test_rs274x.py +++ b/gerber/tests/test_rs274x.py @@ -23,8 +23,8 @@ def test_comments_parameter(): def test_size_parameter(): top_copper = read(TOP_COPPER_FILE) size = top_copper.size - assert_equal(size[0], 2.2869) - assert_equal(size[1], 1.8064) + assert_almost_equal(size[0], 2.256900, 6) + assert_almost_equal(size[1], 1.500000, 6) def test_conversion(): import copy |