summaryrefslogtreecommitdiff
path: root/gerbonara/apertures.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-02-17 00:03:04 +0100
committerjaseg <git@jaseg.de>2023-02-17 00:03:04 +0100
commitf64b03efc752b682b1cbe8cfb114f19e3362ef76 (patch)
tree182bfb4e9b23766d00f255f4d50b183a4d525bcf /gerbonara/apertures.py
parentfb52e104081138a1f6abb8f6c9f7d0c6c2439c1e (diff)
downloadgerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.gz
gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.bz2
gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.zip
Add CLI
Diffstat (limited to 'gerbonara/apertures.py')
-rw-r--r--gerbonara/apertures.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gerbonara/apertures.py b/gerbonara/apertures.py
index d0e1bcb..a30cf13 100644
--- a/gerbonara/apertures.py
+++ b/gerbonara/apertures.py
@@ -251,6 +251,12 @@ class CircleAperture(Aperture):
else:
return self.to_macro(self.rotation)
+ def scaled(self, scale):
+ return replace(self,
+ diameter=self.diameter*scale,
+ hold_dia=None if self.hole_dia is None else self.hole_dia*scale,
+ hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale)
+
def to_macro(self):
return ApertureMacroInstance(GenericMacros.circle, self._params(unit=MM))
@@ -300,6 +306,13 @@ class RectangleAperture(Aperture):
else: # odd angle
return self.to_macro()
+ def scaled(self, scale):
+ return replace(self,
+ w=self.w*scale,
+ h=self.h*scale,
+ hold_dia=None if self.hole_dia is None else self.hole_dia*scale,
+ hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale)
+
def to_macro(self):
return ApertureMacroInstance(GenericMacros.rect,
[MM(self.w, self.unit),
@@ -358,6 +371,13 @@ class ObroundAperture(Aperture):
else:
return self.to_macro()
+ def scaled(self, scale):
+ return replace(self,
+ w=self.w*scale,
+ h=self.h*scale,
+ hold_dia=None if self.hole_dia is None else self.hole_dia*scale,
+ hold_rect_h=None if self.hole_rect_h is None else self.hole_rect_h*scale)
+
def to_macro(self):
# generic macro only supports w > h so flip x/y if h > w
inst = self if self.w > self.h else replace(self, w=self.h, h=self.w, **_rotate_hole_90(self), rotation=self.rotation-90)
@@ -411,6 +431,11 @@ class PolygonAperture(Aperture):
def _rotated(self):
return self
+ def scaled(self, scale):
+ return replace(self,
+ diameter=self.diameter*scale,
+ hold_dia=None if self.hole_dia is None else self.hole_dia*scale)
+
def to_macro(self):
return ApertureMacroInstance(GenericMacros.polygon, self._params(MM))
@@ -462,6 +487,9 @@ class ApertureMacroInstance(Aperture):
def to_macro(self):
return replace(self, macro=self.macro.rotated(self.rotation), rotation=0)
+ def scaled(self, scale):
+ return replace(self, macro=self.macro.scaled(scale))
+
def __eq__(self, other):
return hasattr(other, 'macro') and self.macro == other.macro and \
hasattr(other, 'parameters') and self.parameters == other.parameters and \