diff options
author | jaseg <git@jaseg.de> | 2021-12-29 22:34:01 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-12-29 22:34:01 +0100 |
commit | a0e8aa16e1a34a8309f9fefed90fd5ddf6b33709 (patch) | |
tree | 512ec1f760afb3623f879a8a956d62cd4b48413f /gerbonara/gerber/graphic_objects.py | |
parent | d8ff4a468b7299a370905b5c12c62393e369c61a (diff) | |
download | gerbonara-a0e8aa16e1a34a8309f9fefed90fd5ddf6b33709.tar.gz gerbonara-a0e8aa16e1a34a8309f9fefed90fd5ddf6b33709.tar.bz2 gerbonara-a0e8aa16e1a34a8309f9fefed90fd5ddf6b33709.zip |
More fixes
Diffstat (limited to 'gerbonara/gerber/graphic_objects.py')
-rw-r--r-- | gerbonara/gerber/graphic_objects.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gerbonara/gerber/graphic_objects.py b/gerbonara/gerber/graphic_objects.py index 9902dee..8ee8f57 100644 --- a/gerbonara/gerber/graphic_objects.py +++ b/gerbonara/gerber/graphic_objects.py @@ -34,9 +34,17 @@ class Flash(GerberObject): yield FlashStmt(self.x, self.y) class Region(GerberObject): - def __init__(self, outline=[], arc_centers=None, *, polarity_dark): - super().__init__(self, polarity_dark=polarity_dark) - self.poly = gp.ArcPoly() + def __init__(self, outline=None, arc_centers=None, *, polarity_dark): + super().__init__(polarity_dark=polarity_dark) + outline = [] if outline is None else outline + arc_centers = [] if arc_centers is None else arc_centers + self.poly = gp.ArcPoly(outline, arc_centers) + + def __len__(self): + return len(self.poly) + + def __bool__(self): + return bool(self.poly) def with_offset(self, dx, dy): return Region([ (x+dx, y+dy) for x, y in outline ], radii, polarity_dark=self.polarity_dark) @@ -46,7 +54,8 @@ class Region(GerberObject): self.poly.arc_centers = [ gp.rotate_point(x, y, angle, cx, cy) for x, y in self.poly.arc_centers ] def append(self, obj): - if not self.outline: + print('append', obj) + if not self.poly.outline: self.poly.outline.append(obj.p1) self.poly.outline.append(obj.p2) @@ -64,7 +73,7 @@ class Region(GerberObject): yield from gs.set_current_point(self.poly.outline[0]) - for point, arc_center in zip(self.poly.outline, self.poly.arc_centers): + for point, arc_center in zip(self.poly.outline[1:], self.poly.arc_centers): if arc_center is None: yield from gs.set_interpolation_mode(LinearModeStmt) yield InterpolateStmt(*point) |