summaryrefslogtreecommitdiff
path: root/gerber/render
diff options
context:
space:
mode:
Diffstat (limited to 'gerber/render')
-rw-r--r--gerber/render/cairo_backend.py13
-rw-r--r--gerber/render/svgwrite_backend.py10
2 files changed, 17 insertions, 6 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index c1df87a..999269b 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -26,7 +26,7 @@ SCALE = 400.
class GerberCairoContext(GerberContext):
- def __init__(self, surface=None, size=(1000, 1000)):
+ def __init__(self, surface=None, size=(10000, 10000)):
GerberContext.__init__(self)
if surface is None:
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
@@ -58,9 +58,14 @@ class GerberCairoContext(GerberContext):
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
+ elif isinstance(line.aperture, Rectangle):
+ points = [tuple(map(mul, x, self.scale)) for x in line.vertices]
+ self.ctx.set_source_rgba(*color, alpha=self.alpha)
+ self.ctx.set_line_width(0)
+ self.ctx.move_to(*points[0])
+ for point in points[1:]:
+ self.ctx.line_to(*point)
+ self.ctx.fill()
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 279d90f..9e6a5e4 100644
--- a/gerber/render/svgwrite_backend.py
+++ b/gerber/render/svgwrite_backend.py
@@ -68,8 +68,14 @@ class GerberSvgContext(GerberContext):
aline.stroke(opacity=self.alpha)
self.dwg.add(aline)
elif isinstance(line.aperture, Rectangle):
- # TODO: Render rectangle strokes as a polygon...
- pass
+ points = [tuple(map(mul, point, self.scale)) for point in line.vertices]
+ path = self.dwg.path(d='M %f, %f' % points[0],
+ fill=svg_color(color),
+ stroke='none')
+ path.fill(opacity=self.alpha)
+ for point in points[1:]:
+ path.push('L %f, %f' % point)
+ self.dwg.add(path)
def _render_arc(self, arc, color):
start = tuple(map(mul, arc.start, self.scale))