diff options
Diffstat (limited to 'gerber/render/render.py')
-rw-r--r-- | gerber/render/render.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/gerber/render/render.py b/gerber/render/render.py index 737061e..6ae9392 100644 --- a/gerber/render/render.py +++ b/gerber/render/render.py @@ -133,8 +133,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): @@ -151,10 +156,30 @@ class GerberContext(object): self._render_polygon(primitive, color) elif isinstance(primitive, Drill): self._render_drill(primitive, self.drill_color) + elif isinstance(primitive, Slot): + self._render_slot(primitive, self.drill_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 @@ -179,6 +204,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 |