summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgerber/excellon.py4
-rw-r--r--gerber/primitives.py17
-rw-r--r--gerber/render/cairo_backend.py1
3 files changed, 18 insertions, 4 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index 4ff2161..85821e5 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -634,7 +634,11 @@ def _layer_size_score(size, hole_count, hole_area):
Lower is better.
"""
board_area = size[0] * size[1]
+ if board_area == 0:
+ return 0
+
hole_percentage = hole_area / board_area
hole_score = (hole_percentage - 0.25) ** 2
size_score = (board_area - 8) **2
return hole_score * size_score
+ \ No newline at end of file
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 1e26f19..3f68496 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -256,10 +256,19 @@ class Arc(Primitive):
if theta1 <= math.pi * 1.5 and (theta0 >= math.pi * 1.5 or theta0 < theta1):
points.append((self.center[0], self.center[1] - self.radius ))
x, y = zip(*points)
- min_x = min(x) - self.aperture.radius
- max_x = max(x) + self.aperture.radius
- min_y = min(y) - self.aperture.radius
- max_y = max(y) + self.aperture.radius
+
+ if isinstance(self.aperture, Circle):
+ radius = self.aperture.radius
+ else:
+ # TODO this is actually not valid, but files contain it
+ width = self.aperture.width
+ height = self.aperture.height
+ radius = max(width, height)
+
+ min_x = min(x) - radius
+ max_x = max(x) + radius
+ min_y = min(y) - radius
+ max_y = max(y) + radius
return ((min_x, max_x), (min_y, max_y))
def offset(self, x_offset=0, y_offset=0):
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 4a0724f..4d71199 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -87,6 +87,7 @@ class GerberCairoContext(GerberContext):
else:
self.ctx.arc_negative(center[0], center[1], radius, angle1, angle2)
self.ctx.move_to(*end) # ...lame
+ self.ctx.stroke()
def _render_region(self, region, color):
self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)