diff options
author | Garret Fick <garret@ficksworkshop.com> | 2016-06-25 16:46:44 +0800 |
---|---|---|
committer | Garret Fick <garret@ficksworkshop.com> | 2016-06-25 16:46:44 +0800 |
commit | ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d (patch) | |
tree | 0f752f20823644f1950ab6bd4c85e66700498602 /gerber/render/cairo_backend.py | |
parent | efcb221fc7bd8dae583357e6c4e1c2d3fc9e9df6 (diff) | |
download | gerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.tar.gz gerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.tar.bz2 gerbonara-ccb6eb7a766bd6edf314978f3ec4fc0dcd61652d.zip |
Add support for polygon apertures
Diffstat (limited to 'gerber/render/cairo_backend.py')
-rw-r--r-- | gerber/render/cairo_backend.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index c1bd60c..2b7c2ff 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -159,6 +159,9 @@ class GerberCairoContext(GerberContext): self._render_rectangle(obround.subshapes['rectangle'], color)
def _render_polygon(self, polygon, color):
+ if polygon.hole_radius > 0:
+ self.ctx.push_group()
+
vertices = polygon.vertices
self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)
@@ -172,6 +175,18 @@ class GerberCairoContext(GerberContext): self.ctx.line_to(*map(mul, v, self.scale))
self.ctx.fill()
+
+ if polygon.hole_radius > 0:
+ # Render the center clear
+ center = tuple(map(mul, polygon.position, self.scale))
+ self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)
+ self.ctx.set_operator(cairo.OPERATOR_CLEAR)
+ self.ctx.set_line_width(0)
+ self.ctx.arc(center[0], center[1], polygon.hole_radius * self.scale[0], 0, 2 * math.pi)
+ self.ctx.fill()
+
+ self.ctx.pop_group_to_source()
+ self.ctx.paint_with_alpha(1)
def _render_drill(self, circle, color):
self._render_circle(circle, color)
|