diff options
author | jaseg <git@jaseg.de> | 2023-02-17 00:03:04 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-02-17 00:03:04 +0100 |
commit | f64b03efc752b682b1cbe8cfb114f19e3362ef76 (patch) | |
tree | 182bfb4e9b23766d00f255f4d50b183a4d525bcf /gerbonara/aperture_macros/primitive.py | |
parent | fb52e104081138a1f6abb8f6c9f7d0c6c2439c1e (diff) | |
download | gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.gz gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.tar.bz2 gerbonara-f64b03efc752b682b1cbe8cfb114f19e3362ef76.zip |
Add CLI
Diffstat (limited to 'gerbonara/aperture_macros/primitive.py')
-rw-r--r-- | gerbonara/aperture_macros/primitive.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gerbonara/aperture_macros/primitive.py b/gerbonara/aperture_macros/primitive.py index 47ae87b..579c701 100644 --- a/gerbonara/aperture_macros/primitive.py +++ b/gerbonara/aperture_macros/primitive.py @@ -93,6 +93,12 @@ class Circle(Primitive): def dilate(self, offset, unit): self.diameter += UnitExpression(offset, unit) + def scale(self, scale): + self.x *= UnitExpression(scale) + self.y *= UnitExpression(scale) + self.diameter *= UnitExpression(scale) + + class VectorLine(Primitive): code = 20 exposure : Expression @@ -120,6 +126,12 @@ class VectorLine(Primitive): def dilate(self, offset, unit): self.width += UnitExpression(2*offset, unit) + def scale(self, scale): + self.start_x *= UnitExpression(scale) + self.start_y *= UnitExpression(scale) + self.end_x *= UnitExpression(scale) + self.end_y *= UnitExpression(scale) + class CenterLine(Primitive): code = 21 @@ -142,6 +154,12 @@ class CenterLine(Primitive): def dilate(self, offset, unit): self.width += UnitExpression(2*offset, unit) + + def scale(self, scale): + self.width *= UnitExpression(scale) + self.height *= UnitExpression(scale) + self.x *= UnitExpression(scale) + self.y *= UnitExpression(scale) class Polygon(Primitive): @@ -165,6 +183,11 @@ class Polygon(Primitive): def dilate(self, offset, unit): self.diameter += UnitExpression(2*offset, unit) + def scale(self, scale): + self.diameter *= UnitExpression(scale) + self.x *= UnitExpression(scale) + self.y *= UnitExpression(scale) + class Thermal(Primitive): code = 7 @@ -197,6 +220,13 @@ class Thermal(Primitive): # producing macros that may evaluate to primitives with negative values. warnings.warn('Attempted dilation of macro aperture thermal primitive. This is not supported.') + def scale(self, scale): + self.d_outer *= UnitExpression(scale) + self.d_inner *= UnitExpression(scale) + self.gap_w *= UnitExpression(scale) + self.x *= UnitExpression(scale) + self.y *= UnitExpression(scale) + class Outline(Primitive): code = 4 @@ -244,6 +274,9 @@ class Outline(Primitive): # we would need a whole polygon offset/clipping library here warnings.warn('Attempted dilation of macro aperture outline primitive. This is not supported.') + def scale(self, scale): + self.coords = [(x*UnitExpression(scale), y*UnitExpression(scale)) for x, y in self.coords] + class Comment: code = 0 @@ -254,6 +287,9 @@ class Comment: def to_gerber(self, unit=None): return f'0 {self.comment}' + def scale(self, scale): + pass + PRIMITIVE_CLASSES = { **{cls.code: cls for cls in [ Comment, |