diff options
author | jaseg <git@jaseg.de> | 2024-07-19 19:28:15 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2024-07-19 19:28:15 +0200 |
commit | 091ee84910bdd6e30988ee7c9061b6d474f588db (patch) | |
tree | bab3a23a270c6877ff3b38f7584dccd2069636fc /gerbonara/cad/kicad | |
parent | fd63c443143ad58c3a44d3ecddaed28ff95992ff (diff) | |
download | gerbonara-091ee84910bdd6e30988ee7c9061b6d474f588db.tar.gz gerbonara-091ee84910bdd6e30988ee7c9061b6d474f588db.tar.bz2 gerbonara-091ee84910bdd6e30988ee7c9061b6d474f588db.zip |
kicad: add rotation method to circles and polygons
Diffstat (limited to 'gerbonara/cad/kicad')
-rw-r--r-- | gerbonara/cad/kicad/graphical_primitives.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gerbonara/cad/kicad/graphical_primitives.py b/gerbonara/cad/kicad/graphical_primitives.py index 1583e04..f86fcc7 100644 --- a/gerbonara/cad/kicad/graphical_primitives.py +++ b/gerbonara/cad/kicad/graphical_primitives.py @@ -182,6 +182,10 @@ class Circle(BBoxMixin, WidthMixin): self.center = self.center.with_offset(x, y) self.end = self.end.with_offset(x, y) + def rotate(self, angle, cx=0, cy=0): + self.center = self.center.with_rotation(angle, cx, cy) + self.end = self.end.with_rotation(angle, cx, cy) + @sexp_type('gr_arc') class Arc(WidthMixin, BBoxMixin): @@ -205,11 +209,6 @@ class Arc(WidthMixin, BBoxMixin): self.mid = center_arc_to_kicad_mid(XYCoord(self.center), self.start, self.end) self.center = None - def rotate(self, angle, cx=None, cy=None): - self.start.x, self.start.y = rotate_point(self.start.x, self.start.y, angle, cx, cy) - self.mid.x, self.mid.y = rotate_point(self.mid.x, self.mid.y, angle, cx, cy) - self.end.x, self.end.y = rotate_point(self.end.x, self.end.y, angle, cx, cy) - def render(self, variables=None): if not (w := self.stroke.width if self.stroke else self.width): return @@ -225,6 +224,11 @@ class Arc(WidthMixin, BBoxMixin): self.mid = self.mid.with_offset(x, y) self.end = self.end.with_offset(x, y) + def rotate(self, angle, cx=None, cy=None): + self.start.x, self.start.y = rotate_point(self.start.x, self.start.y, angle, cx, cy) + self.mid.x, self.mid.y = rotate_point(self.mid.x, self.mid.y, angle, cx, cy) + self.end.x, self.end.y = rotate_point(self.end.x, self.end.y, angle, cx, cy) + @sexp_type('gr_poly') class Polygon(BBoxMixin, WidthMixin): @@ -266,6 +270,9 @@ class Polygon(BBoxMixin, WidthMixin): def offset(self, x=0, y=0): self.pts = [pt.with_offset(x, y) for pt in self.pts] + def rotate(self, angle, cx=0, cy=0): + self.pts = [pt.with_rotation(angle, cx, cy) for pt in self.pts] + @sexp_type('gr_curve') class Curve(BBoxMixin, WidthMixin): |