From 7f47aea332ee1df45c87baa304d95ed03cc59865 Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Sat, 5 Mar 2016 10:04:58 +0800 Subject: Write polygons to macros --- gerber/primitives.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gerber/primitives.py') diff --git a/gerber/primitives.py b/gerber/primitives.py index 3c85f17..08aa634 100644 --- a/gerber/primitives.py +++ b/gerber/primitives.py @@ -736,6 +736,10 @@ class Polygon(Primitive): @property def flashed(self): return True + + @property + def diameter(self): + return self.radius * 2 @property def bounding_box(self): @@ -759,6 +763,20 @@ class Polygon(Primitive): points.append(rotate_point((self.position[0] + self.radius, self.position[1]), offset + da * i, self.position)) return points + + def equivalent(self, other, offset): + ''' + Is this the outline the same as the other, ignoring the position offset? + ''' + + # Quick check if it even makes sense to compare them + if type(self) != type(other) or self.sides != other.sides or self.radius != other.radius: + return False + + equiv_pos = tuple(map(add, other.position, offset)) + + return nearly_equal(self.position, equiv_pos) + class AMGroup(Primitive): """ -- cgit