summaryrefslogtreecommitdiff
path: root/gerber/primitives.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-02 00:43:08 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-02 00:43:08 -0500
commitd98d23f8b5d61bb9d20e743a3c44bf04b6b2330a (patch)
tree8e11666ac2d36aa351d28c457165a688f73f4df9 /gerber/primitives.py
parent360eddc3c421cc193716b17d33cc94d8444d64ce (diff)
downloadgerbonara-d98d23f8b5d61bb9d20e743a3c44bf04b6b2330a.tar.gz
gerbonara-d98d23f8b5d61bb9d20e743a3c44bf04b6b2330a.tar.bz2
gerbonara-d98d23f8b5d61bb9d20e743a3c44bf04b6b2330a.zip
More tests and bugfixes
Diffstat (limited to 'gerber/primitives.py')
-rw-r--r--gerber/primitives.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 61df7c1..da05127 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -345,20 +345,25 @@ class Obround(Primitive):
self.position = position
self.width = width
self.height = height
-
- @property
- def orientation(self):
- return 'vertical' if self.height > self.width else 'horizontal'
+ # Axis-aligned width and height
+ self._abs_width = (math.cos(math.radians(self.rotation)) * self.width +
+ math.sin(math.radians(self.rotation)) * self.height)
+ self._abs_height = (math.cos(math.radians(self.rotation)) * self.height +
+ math.sin(math.radians(self.rotation)) * self.width)
@property
def lower_left(self):
- return (self.position[0] - (self.width / 2.),
- self.position[1] - (self.height / 2.))
+ return (self.position[0] - (self._abs_width / 2.),
+ self.position[1] - (self._abs_height / 2.))
@property
def upper_right(self):
- return (self.position[0] + (self.width / 2.),
- self.position[1] + (self.height / 2.))
+ return (self.position[0] + (self._abs_width / 2.),
+ self.position[1] + (self._abs_height / 2.))
+
+ @property
+ def orientation(self):
+ return 'vertical' if self.height > self.width else 'horizontal'
@property
def bounding_box(self):
@@ -380,7 +385,7 @@ class Obround(Primitive):
else:
circle1 = Circle((self.position[0] - (self.height - self.width) / 2.,
self.position[1]), self.height)
- circle2 = Circle((self.position[0] - (self.height - self.width) / 2.,
+ circle2 = Circle((self.position[0] + (self.height - self.width) / 2.,
self.position[1]), self.height)
rect = Rectangle(self.position, (self.width - self.height),
self.height)