diff options
author | jaseg <git@jaseg.de> | 2022-01-18 01:10:16 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-01-18 01:10:16 +0100 |
commit | d85790bc6d40deb1d52cc5d8a4c178f664635625 (patch) | |
tree | 8be76c210974a2dbd1f11c5eecfee015c46f9d83 /gerbonara/gerber/graphic_objects.py | |
parent | 73a44901c0ef0e94e9465c2f35750ca6f85a4473 (diff) | |
download | gerbonara-d85790bc6d40deb1d52cc5d8a4c178f664635625.tar.gz gerbonara-d85790bc6d40deb1d52cc5d8a4c178f664635625.tar.bz2 gerbonara-d85790bc6d40deb1d52cc5d8a4c178f664635625.zip |
Unit code refactor WIP
Diffstat (limited to 'gerbonara/gerber/graphic_objects.py')
-rw-r--r-- | gerbonara/gerber/graphic_objects.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gerbonara/gerber/graphic_objects.py b/gerbonara/gerber/graphic_objects.py index e251540..f97aff4 100644 --- a/gerbonara/gerber/graphic_objects.py +++ b/gerbonara/gerber/graphic_objects.py @@ -27,15 +27,15 @@ class GerberObject: def converted(self, unit): return replace(self, - **{ f.name: self.unit.to(unit, getattr(self, f.name)) + **{ f.name: self.unit.convert_to(unit, getattr(self, f.name)) for f in fields(self) if type(f.type) is Length }) def with_offset(self, dx, dy, unit=MM): - dx, dy = self.unit.from(unit, dx), self.unit.from(unit, dy) + dx, dy = self.unit(dx, unit), self.unit(dy, unit) return self._with_offset(dx, dy) def rotate(self, rotation, cx=0, cy=0, unit=MM): - cx, cy = self.unit.from(unit, cx), self.unit.from(unit, cy) + cx, cy = self.unit(cx, unit), self.unit(cy, unit) self._rotate(rotation, cx, cy) def bounding_box(self, unit=None): @@ -133,7 +133,7 @@ class Region(GerberObject): if unit == self.unit: yield self.poly else: - to = lambda value: self.unit.to(unit, value) + to = lambda value: self.unit.convert_to(unit, value) conv_outline = [ (to(x), to(y)) for x, y in self.poly.outline ] convert_entry = lambda entry: (entry[0], (to(entry[1][0]), to(entry[1][1]))) @@ -219,7 +219,7 @@ class Line(GerberObject): ctx.set_current_point(self.unit, *self.p2) def curve_length(self, unit=MM): - return self.unit.to(unit, math.dist(self.p1, self.p2)) + return self.unit.convert_to(unit, math.dist(self.p1, self.p2)) @dataclass @@ -307,6 +307,6 @@ class Arc(GerberObject): if f > math.pi: f = 2*math.pi - f - return self.unit.to(unit, 2*math.pi*r * (f/math.pi)) + return self.unit.convert_to(unit, 2*math.pi*r * (f/math.pi)) |