summaryrefslogtreecommitdiff
path: root/gerbonara/graphic_primitives.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-02-04 22:10:19 +0100
committerjaseg <git@jaseg.de>2022-02-04 22:10:19 +0100
commit4cbda84aa61158c06acc78aac4b318bbea5b6214 (patch)
tree7b5724b019324bbadd862076ece399a73a670b90 /gerbonara/graphic_primitives.py
parenteaf4f21ce65081da0490a41ee1829b4ec8319109 (diff)
downloadgerbonara-4cbda84aa61158c06acc78aac4b318bbea5b6214.tar.gz
gerbonara-4cbda84aa61158c06acc78aac4b318bbea5b6214.tar.bz2
gerbonara-4cbda84aa61158c06acc78aac4b318bbea5b6214.zip
More doc, fix tests
Diffstat (limited to 'gerbonara/graphic_primitives.py')
-rw-r--r--gerbonara/graphic_primitives.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/gerbonara/graphic_primitives.py b/gerbonara/graphic_primitives.py
index 6e785d9..df49327 100644
--- a/gerbonara/graphic_primitives.py
+++ b/gerbonara/graphic_primitives.py
@@ -104,12 +104,12 @@ class ArcPoly(GraphicPrimitive):
def from_regular_polygon(kls, x:float, y:float, r:float, n:int, rotation:float=0, polarity_dark:bool=True):
""" Convert an n-sided gerber polygon to a normal ArcPoly defined by outline """
- delta = 2*math.pi / self.n
+ delta = 2*math.pi / n
return kls([
- (self.x + math.cos(self.rotation + i*delta) * self.r,
- self.y + math.sin(self.rotation + i*delta) * self.r)
- for i in range(self.n) ], polarity_dark=polarity_dark)
+ (x + math.cos(rotation + i*delta) * r,
+ y + math.sin(rotation + i*delta) * r)
+ for i in range(n) ], polarity_dark=polarity_dark)
def __len__(self):
""" Return the number of points on this polygon's outline (which is also the number of segments because the
@@ -156,15 +156,15 @@ class Line(GraphicPrimitive):
@classmethod
def from_obround(kls, x:float, y:float, w:float, h:float, rotation:float=0, polarity_dark:bool=True):
""" Convert a gerber obround into a :py:class:`~.graphic_primitives.Line`. """
- if self.w > self.h:
- w, a, b = self.h, self.w-self.h, 0
+ if w > h:
+ w, a, b = h, w-h, 0
else:
- w, a, b = self.w, 0, self.h-self.w
+ w, a, b = w, 0, h-w
return kls(
- *rotate_point(self.x-a/2, self.y-b/2, self.rotation, self.x, self.y),
- *rotate_point(self.x+a/2, self.y+b/2, self.rotation, self.x, self.y),
- w, polarity_dark=self.polarity_dark)
+ *rotate_point(x-a/2, y-b/2, rotation, x, y),
+ *rotate_point(x+a/2, y+b/2, rotation, x, y),
+ w, polarity_dark=polarity_dark)
def bounding_box(self):
r = self.width / 2