summaryrefslogtreecommitdiff
path: root/gerber/primitives.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-03-01 00:06:14 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-03-01 00:06:14 +0800
commit20a9af279ac2217a39b73903ff94b916a3025be2 (patch)
tree2d4c6a16733a38941280a79ee274c28466f1b377 /gerber/primitives.py
parent223a010831f0d9dae4bd6d2e626a603a78eb0b1d (diff)
downloadgerbonara-20a9af279ac2217a39b73903ff94b916a3025be2.tar.gz
gerbonara-20a9af279ac2217a39b73903ff94b916a3025be2.tar.bz2
gerbonara-20a9af279ac2217a39b73903ff94b916a3025be2.zip
More rendering of AMGroup to statements
Diffstat (limited to 'gerber/primitives.py')
-rw-r--r--gerber/primitives.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 07a28db..3c85f17 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -397,6 +397,19 @@ class Circle(Primitive):
def offset(self, x_offset=0, y_offset=0):
self.position = tuple(map(add, self.position, (x_offset, y_offset)))
+
+ def equivalent(self, other, offset):
+ '''Is this the same as the other circle, ignoring the offiset?'''
+
+ if not isinstance(other, Circle):
+ return False
+
+ if self.diameter != other.diameter:
+ return False
+
+ equiv_position = tuple(map(add, other.position, offset))
+
+ return nearly_equal(self.position, equiv_position)
class Ellipse(Primitive):
@@ -487,6 +500,19 @@ class Rectangle(Primitive):
return (math.cos(math.radians(self.rotation)) * self.height +
math.sin(math.radians(self.rotation)) * self.width)
+ def equivalent(self, other, offset):
+ '''Is this the same as the other rect, ignoring the offiset?'''
+
+ if not isinstance(other, Rectangle):
+ return False
+
+ if self.width != other.width or self.height != other.height or self.rotation != other.rotation:
+ return False
+
+ equiv_position = tuple(map(add, other.position, offset))
+
+ return nearly_equal(self.position, equiv_position)
+
class Diamond(Primitive):
"""
@@ -815,6 +841,9 @@ class Outline(Primitive):
self.primitives = primitives
self._to_convert = ['primitives']
+ if self.primitives[0].start != self.primitives[-1].end:
+ raise ValueError('Outline must be closed')
+
@property
def flashed(self):
return True
@@ -833,6 +862,9 @@ class Outline(Primitive):
def offset(self, x_offset=0, y_offset=0):
for p in self.primitives:
p.offset(x_offset, y_offset)
+
+ if self.primitives[0].start != self.primitives[-1].end:
+ raise ValueError('Outline must be closed')
@property
def width(self):