From 83ae0670d11b5f5ef8ba3a6c362b7129a9e31ab3 Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Fri, 8 Jan 2016 00:19:47 +0800 Subject: More stability fixes for poorly constructed files --- gerber/render/cairo_backend.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gerber/render') diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index 68e9e98..fbc4271 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -76,7 +76,10 @@ class GerberCairoContext(GerberContext): radius = self.scale[0] * arc.radius angle1 = arc.start_angle angle2 = arc.end_angle - width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001 + if isinstance(arc.aperture, Circle): + width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001 + else: + width = max(arc.aperture.width, arc.aperture.height, 0.001) self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha) self.ctx.set_operator(cairo.OPERATOR_OVER if (arc.level_polarity == "dark" and not self.invert)else cairo.OPERATOR_CLEAR) self.ctx.set_line_width(width * self.scale[0]) @@ -163,7 +166,6 @@ class GerberCairoContext(GerberContext): self.ctx.line_to(*map(mul, v, self.scale)) self.ctx.fill() - def _render_drill(self, circle, color): self._render_circle(circle, color) -- cgit