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/svgwrite_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/svgwrite_backend.py')
-rw-r--r-- | gerber/render/svgwrite_backend.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/gerber/render/svgwrite_backend.py b/gerber/render/svgwrite_backend.py index 27783d6..279d90f 100644 --- a/gerber/render/svgwrite_backend.py +++ b/gerber/render/svgwrite_backend.py @@ -21,6 +21,8 @@ from operator import mul import math import svgwrite +from ..primitives import * + SCALE = 400. @@ -57,13 +59,17 @@ class GerberSvgContext(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 - aline = self.dwg.line(start=start, end=end, - stroke=svg_color(color), - stroke_width=SCALE * width, - stroke_linecap='round') - aline.stroke(opacity=self.alpha) - self.dwg.add(aline) + if isinstance(line.aperture, Circle): + width = line.aperture.diameter if line.aperture.diameter != 0 else 0.001 + aline = self.dwg.line(start=start, end=end, + stroke=svg_color(color), + stroke_width=SCALE * width, + stroke_linecap='round') + aline.stroke(opacity=self.alpha) + self.dwg.add(aline) + elif isinstance(line.aperture, Rectangle): + # TODO: Render rectangle strokes as a polygon... + pass def _render_arc(self, arc, color): start = tuple(map(mul, arc.start, self.scale)) |