From f61eee807f87c329f6f88645ecdb48f01b887c52 Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Wed, 30 Dec 2015 18:44:07 +0800 Subject: Render polygon flashes --- gerber/render/cairo_backend.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gerber/render') 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) -- cgit