summaryrefslogtreecommitdiff
path: root/gerber/render
diff options
context:
space:
mode:
Diffstat (limited to 'gerber/render')
-rw-r--r--gerber/render/cairo_backend.py20
-rw-r--r--gerber/render/svgwrite_backend.py20
2 files changed, 26 insertions, 14 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)
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))