summaryrefslogtreecommitdiff
path: root/gerber/render/render.py
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2016-11-16 23:54:09 -0200
committerGitHub <noreply@github.com>2016-11-16 23:54:09 -0200
commit521fe89150c6aaa0ff0954cc8d32e4b6f8009324 (patch)
tree59cef68f1449a5be8d2a9a8ed352e3d9974a3edb /gerber/render/render.py
parent7030eee5e28180732c5cf98aeda4b66657223870 (diff)
parent1e868763a1c4030bedd51553468cbe25f272bef9 (diff)
downloadgerbonara-521fe89150c6aaa0ff0954cc8d32e4b6f8009324.tar.gz
gerbonara-521fe89150c6aaa0ff0954cc8d32e4b6f8009324.tar.bz2
gerbonara-521fe89150c6aaa0ff0954cc8d32e4b6f8009324.zip
Merge pull request #58 from garretfick/merge-curtacircuitos
Epic merge from @garretfick Thanks a lot @garretfick and @hamiltonkibbe.
Diffstat (limited to 'gerber/render/render.py')
-rw-r--r--gerber/render/render.py48
1 files changed, 44 insertions, 4 deletions
diff --git a/gerber/render/render.py b/gerber/render/render.py
index 724aaea..79f43d6 100644
--- a/gerber/render/render.py
+++ b/gerber/render/render.py
@@ -65,7 +65,7 @@ class GerberContext(object):
self._background_color = (0.0, 0.0, 0.0)
self._drill_color = (0.0, 0.0, 0.0)
self._alpha = 1.0
- self.invert = False
+ self._invert = False
self.ctx = None
@property
@@ -127,7 +127,20 @@ class GerberContext(object):
raise ValueError('Alpha must be between 0.0 and 1.0')
self._alpha = alpha
+ @property
+ def invert(self):
+ return self._invert
+
+ @invert.setter
+ def invert(self, invert):
+ self._invert = invert
+
def render(self, primitive):
+ if not primitive:
+ return
+
+ self._pre_render_primitive(primitive)
+
color = self.color
if isinstance(primitive, Line):
self._render_line(primitive, color)
@@ -144,11 +157,32 @@ 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
@@ -174,6 +208,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