summaryrefslogtreecommitdiff
path: root/gerber/render
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2015-12-30 14:05:00 +0800
committerGarret Fick <garret@ficksworkshop.com>2015-12-30 14:05:00 +0800
commit4a815bf25ddd1d378ec6ad5af008e5bbcd362b51 (patch)
treec9bd8f971d488e71a88cd4e48703533d301f9167 /gerber/render
parentca3c682da59bd83c460a3e51ed3a80280f909d49 (diff)
downloadgerbonara-4a815bf25ddd1d378ec6ad5af008e5bbcd362b51.tar.gz
gerbonara-4a815bf25ddd1d378ec6ad5af008e5bbcd362b51.tar.bz2
gerbonara-4a815bf25ddd1d378ec6ad5af008e5bbcd362b51.zip
First time any macro renders
Diffstat (limited to 'gerber/render')
-rw-r--r--gerber/render/cairo_backend.py20
-rw-r--r--gerber/render/render.py5
2 files changed, 25 insertions, 0 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 4d71199..3ee38ae 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -122,11 +122,27 @@ class GerberCairoContext(GerberContext):
def _render_rectangle(self, rectangle, color):
ll = map(mul, rectangle.lower_left, self.scale)
width, height = tuple(map(mul, (rectangle.width, rectangle.height), map(abs, self.scale)))
+
+ if rectangle.rotation != 0:
+ self.ctx.save()
+
+ center = map(mul, rectangle.position, self.scale)
+ matrix = cairo.Matrix()
+ matrix.translate(center[0], center[1])
+ # For drawing, we already handles the translation
+ ll[0] = ll[0] - center[0]
+ ll[1] = ll[1] - center[1]
+ matrix.rotate(rectangle.rotation)
+ self.ctx.transform(matrix)
+
self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)
self.ctx.set_operator(cairo.OPERATOR_OVER if (rectangle.level_polarity == "dark" and not self.invert) else cairo.OPERATOR_CLEAR)
self.ctx.set_line_width(0)
self.ctx.rectangle(ll[0], ll[1], width, height)
self.ctx.fill()
+
+ if rectangle.rotation != 0:
+ self.ctx.restore()
def _render_obround(self, obround, color):
self._render_circle(obround.subshapes['circle1'], color)
@@ -135,6 +151,10 @@ class GerberCairoContext(GerberContext):
def _render_drill(self, circle, color):
self._render_circle(circle, color)
+
+ def _render_amgroup(self, amgroup, color):
+ for primitive in amgroup.primitives:
+ self.render(primitive)
def _render_test_record(self, primitive, color):
self.ctx.select_font_face('monospace', cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
diff --git a/gerber/render/render.py b/gerber/render/render.py
index 8f49796..ac01e52 100644
--- a/gerber/render/render.py
+++ b/gerber/render/render.py
@@ -150,6 +150,8 @@ class GerberContext(object):
self._render_polygon(primitive, color)
elif isinstance(primitive, Drill):
self._render_drill(primitive, self.drill_color)
+ elif isinstance(primitive, AMGroup):
+ self._render_amgroup(primitive, color)
elif isinstance(primitive, TestRecord):
self._render_test_record(primitive, color)
else:
@@ -178,6 +180,9 @@ class GerberContext(object):
def _render_drill(self, primitive, color):
pass
+
+ def _render_amgroup(self, primitive, color):
+ pass
def _render_test_record(self, primitive, color):
pass