summaryrefslogtreecommitdiff
path: root/gerber/render
diff options
context:
space:
mode:
Diffstat (limited to 'gerber/render')
-rw-r--r--gerber/render/cairo_backend.py12
-rw-r--r--gerber/render/render.py6
2 files changed, 16 insertions, 2 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 326f44e..fa1aecc 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -104,7 +104,7 @@ class GerberCairoContext(GerberContext):
self.ctx.fill()
def _render_circle(self, circle, color):
- center = map(mul, circle.position, self.scale)
+ center = tuple(map(mul, circle.position, self.scale))
self.ctx.set_source_rgba(*color, alpha=self.alpha)
self.ctx.set_line_width(0)
self.ctx.arc(*center, radius=circle.radius * SCALE, angle1=0, angle2=2 * math.pi)
@@ -126,5 +126,15 @@ class GerberCairoContext(GerberContext):
def _render_drill(self, circle, color):
self._render_circle(circle, color)
+ def _render_test_record(self, primitive, color):
+ self.ctx.select_font_face('monospace', cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
+ self.ctx.set_font_size(200)
+ self._render_circle(Circle(primitive.position, 0.01), color)
+ self.ctx.set_source_rgb(*color)
+ self.ctx.move_to(*[SCALE * (coord + 0.01) for coord in primitive.position])
+ self.ctx.scale(1, -1)
+ self.ctx.show_text(primitive.net_name)
+ self.ctx.scale(1, -1)
+
def dump(self, filename):
self.surface.write_to_png(filename)
diff --git a/gerber/render/render.py b/gerber/render/render.py
index 2e4abfa..68c2115 100644
--- a/gerber/render/render.py
+++ b/gerber/render/render.py
@@ -138,9 +138,11 @@ class GerberContext(object):
elif isinstance(primitive, Obround):
self._render_obround(primitive, color)
elif isinstance(primitive, Polygon):
- self._render_polygon(Polygon, color)
+ self._render_polygon(primitive, color)
elif isinstance(primitive, Drill):
self._render_drill(primitive, self.drill_color)
+ elif isinstance(primitive, TestRecord):
+ self._render_test_record(primitive, color)
else:
return
@@ -168,3 +170,5 @@ class GerberContext(object):
def _render_drill(self, primitive, color):
pass
+ def _render_test_record(self, primitive, color):
+ pass