From 206f4c57ab66f8a6753015340315991b40178c9b Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Wed, 16 Dec 2015 18:59:25 +0800 Subject: Fix drawing arcs. Dont crash for arcs with rectangular apertures. Fix crash with board size of zero for only one drill --- gerber/primitives.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'gerber/primitives.py') 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): -- cgit