diff options
author | Garret Fick <garret@ficksworkshop.com> | 2015-12-30 18:44:07 +0800 |
---|---|---|
committer | Garret Fick <garret@ficksworkshop.com> | 2015-12-30 18:44:07 +0800 |
commit | f61eee807f87c329f6f88645ecdb48f01b887c52 (patch) | |
tree | 9c1422fac612c4bca82968c278540875ae9307e2 /gerber/render | |
parent | ff1ad704d5bb7814fdaebc156b727ec3c5f2d1a8 (diff) | |
download | gerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.tar.gz gerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.tar.bz2 gerbonara-f61eee807f87c329f6f88645ecdb48f01b887c52.zip |
Render polygon flashes
Diffstat (limited to 'gerber/render')
-rw-r--r-- | gerber/render/cairo_backend.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index 3ee38ae..68e9e98 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -148,6 +148,22 @@ class GerberCairoContext(GerberContext): self._render_circle(obround.subshapes['circle1'], color)
self._render_circle(obround.subshapes['circle2'], color)
self._render_rectangle(obround.subshapes['rectangle'], color)
+
+ def _render_polygon(self, polygon, color):
+ vertices = polygon.vertices
+
+ self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)
+ self.ctx.set_operator(cairo.OPERATOR_OVER if (polygon.level_polarity == "dark" and not self.invert) else cairo.OPERATOR_CLEAR)
+ self.ctx.set_line_width(0)
+ self.ctx.set_line_cap(cairo.LINE_CAP_ROUND)
+
+ # Start from before the end so it is easy to iterate and make sure it is closed
+ self.ctx.move_to(*map(mul, vertices[-1], self.scale))
+ for v in vertices:
+ self.ctx.line_to(*map(mul, v, self.scale))
+
+ self.ctx.fill()
+
def _render_drill(self, circle, color):
self._render_circle(circle, color)
|