diff options
author | Hamilton Kibbe <ham@hamiltonkib.be> | 2015-02-12 11:28:50 -0500 |
---|---|---|
committer | Hamilton Kibbe <ham@hamiltonkib.be> | 2015-02-12 11:28:50 -0500 |
commit | 8f69c1dfa281b6486c8fce16c1d58acef70c7ae7 (patch) | |
tree | 2dec25cbe731e5bf218dc508cdd082286f446edf /gerber/render/cairo_backend.py | |
parent | 41f9475b132001d52064392057e376c6423c33dc (diff) | |
download | gerbonara-8f69c1dfa281b6486c8fce16c1d58acef70c7ae7.tar.gz gerbonara-8f69c1dfa281b6486c8fce16c1d58acef70c7ae7.tar.bz2 gerbonara-8f69c1dfa281b6486c8fce16c1d58acef70c7ae7.zip |
Update line primitive to take aperture parameter
This fixes the exception referenced in #12. Still need to add rendering
code for rectangle aperture lines and arcs.
Rectangle strokes will be drawn as polygons by the rendering backends.
Diffstat (limited to 'gerber/render/cairo_backend.py')
-rw-r--r-- | gerber/render/cairo_backend.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index 125a125..c1df87a 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -20,6 +20,8 @@ from operator import mul import cairocffi as cairo
import math
+from ..primitives import *
+
SCALE = 400.
@@ -48,13 +50,17 @@ class GerberCairoContext(GerberContext): def _render_line(self, line, color):
start = map(mul, line.start, self.scale)
end = map(mul, line.end, self.scale)
- width = line.width if line.width != 0 else 0.001
- self.ctx.set_source_rgba(*color, alpha=self.alpha)
- self.ctx.set_line_width(width * SCALE)
- self.ctx.set_line_cap(cairo.LINE_CAP_ROUND)
- self.ctx.move_to(*start)
- self.ctx.line_to(*end)
- self.ctx.stroke()
+ if isinstance(line.aperture, Circle):
+ width = line.aperture.diameter if line.aperture.diameter != 0 else 0.001
+ self.ctx.set_source_rgba(*color, alpha=self.alpha)
+ self.ctx.set_line_width(width * SCALE)
+ self.ctx.set_line_cap(cairo.LINE_CAP_ROUND)
+ self.ctx.move_to(*start)
+ self.ctx.line_to(*end)
+ self.ctx.stroke()
+ elif isinstance(line.aperture, rectangle):
+ # TODO: Render rectangle strokes as a polygon...
+ pass
def _render_arc(self, arc, color):
center = map(mul, arc.center, self.scale)
|