summaryrefslogtreecommitdiff
path: root/gerber/render/render.py
diff options
context:
space:
mode:
Diffstat (limited to 'gerber/render/render.py')
-rw-r--r--gerber/render/render.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/gerber/render/render.py b/gerber/render/render.py
index 6af8bf1..f521c44 100644
--- a/gerber/render/render.py
+++ b/gerber/render/render.py
@@ -132,8 +132,13 @@ class GerberContext(object):
self._invert = invert
def render(self, primitive):
+ if not primitive:
+ return
color = (self.color if primitive.level_polarity == 'dark'
else self.background_color)
+
+ self._pre_render_primitive(primitive)
+
if isinstance(primitive, Line):
self._render_line(primitive, color)
elif isinstance(primitive, Arc):
@@ -149,11 +154,31 @@ class GerberContext(object):
elif isinstance(primitive, Polygon):
self._render_polygon(primitive, color)
elif isinstance(primitive, Drill):
- self._render_drill(primitive, color)
+ self._render_drill(primitive, self.color)
+ elif isinstance(primitive, Slot):
+ self._render_slot(primitive, self.color)
+ elif isinstance(primitive, AMGroup):
+ self._render_amgroup(primitive, color)
+ elif isinstance(primitive, Outline):
+ self._render_region(primitive, color)
elif isinstance(primitive, TestRecord):
self._render_test_record(primitive, color)
- else:
- return
+
+ self._post_render_primitive(primitive)
+
+ def _pre_render_primitive(self, primitive):
+ """
+ Called before rendering a primitive. Use the callback to perform some action before rendering
+ a primitive, for example adding a comment.
+ """
+ return
+
+ def _post_render_primitive(self, primitive):
+ """
+ Called after rendering a primitive. Use the callback to perform some action after rendering
+ a primitive
+ """
+ return
def _render_line(self, primitive, color):
pass
@@ -178,6 +203,12 @@ class GerberContext(object):
def _render_drill(self, primitive, color):
pass
+
+ def _render_slot(self, primitive, color):
+ pass
+
+ def _render_amgroup(self, primitive, color):
+ pass
def _render_test_record(self, primitive, color):
pass