summaryrefslogtreecommitdiff
path: root/gerber/render/rs274x_backend.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-06-25 16:46:44 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-06-25 16:46:44 +0800
commitccb6eb7a766bd6edf314978f3ec4fc0dcd61652d (patch)
tree0f752f20823644f1950ab6bd4c85e66700498602 /gerber/render/rs274x_backend.py
parentefcb221fc7bd8dae583357e6c4e1c2d3fc9e9df6 (diff)
downloadgerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.tar.gz
gerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.tar.bz2
gerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.zip
Add support for polygon apertures
Diffstat (limited to 'gerber/render/rs274x_backend.py')
-rw-r--r--gerber/render/rs274x_backend.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index bb784b1..c37529e 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -310,7 +310,7 @@ class Rs274xContext(GerberContext):
self._next_dcode = max(dcode + 1, self._next_dcode)
aper = ADParamStmt.obround(dcode, width, height)
- self._obrounds[(width, height)] = aper
+ self._obrounds[key] = aper
self.header.append(aper)
return aper
@@ -320,10 +320,28 @@ class Rs274xContext(GerberContext):
aper = self._get_obround(obround.width, obround.height)
self._render_flash(obround, aper)
- pass
-
def _render_polygon(self, polygon, color):
- raise ValueError('Polygons can only exist in the context of aperture macro')
+
+ aper = self._get_polygon(polygon.radius, polygon.sides, polygon.rotation, polygon.hole_radius)
+ self._render_flash(polygon, aper)
+
+ def _get_polygon(self, radius, num_vertices, rotation, hole_radius, dcode = None):
+
+ key = (radius, num_vertices, rotation, hole_radius)
+ aper = self._polygons.get(key, None)
+
+ if not aper:
+ if not dcode:
+ dcode = self._next_dcode
+ self._next_dcode += 1
+ else:
+ self._next_dcode = max(dcode + 1, self._next_dcode)
+
+ aper = ADParamStmt.polygon(dcode, radius * 2, num_vertices, rotation, hole_radius * 2)
+ self._polygons[key] = aper
+ self.header.append(aper)
+
+ return aper
def _render_drill(self, drill, color):
raise ValueError('Drills are not valid in RS274X files')