diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2014-10-27 08:29:43 -0400 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2014-10-27 08:29:43 -0400 |
commit | 95de179bb08157c3f6716b0645ec00794acc83e6 (patch) | |
tree | 76dc30efcd3eb451541f4e31fcf82a1114bd7f26 /gerber/render/cairo_backend.py | |
parent | 318a81382e074a5897489299a58e029815d23492 (diff) | |
download | gerbonara-95de179bb08157c3f6716b0645ec00794acc83e6.tar.gz gerbonara-95de179bb08157c3f6716b0645ec00794acc83e6.tar.bz2 gerbonara-95de179bb08157c3f6716b0645ec00794acc83e6.zip |
Fix rendering of 0-width lines (e.g. board outlines) in SVG and Cairo renderer
Diffstat (limited to 'gerber/render/cairo_backend.py')
-rw-r--r-- | gerber/render/cairo_backend.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index df513bb..1c69725 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -20,7 +20,7 @@ from operator import mul import cairocffi as cairo
import math
-SCALE = 300.
+SCALE = 400.
class GerberCairoContext(GerberContext):
@@ -48,8 +48,9 @@ class GerberCairoContext(GerberContext): def _render_line(self, line, color):
start = map(mul, line.start, self.scale)
end = map(mul, line.end, self.scale)
- self.ctx.set_source_rgb (*color)
- self.ctx.set_line_width(line.width * 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)
@@ -57,7 +58,7 @@ class GerberCairoContext(GerberContext): def _render_region(self, region, color):
points = [tuple(map(mul, point, self.scale)) for point in region.points]
- self.ctx.set_source_rgb (*color)
+ 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:]:
@@ -66,7 +67,7 @@ class GerberCairoContext(GerberContext): def _render_circle(self, circle, color):
center = map(mul, circle.position, self.scale)
- self.ctx.set_source_rgb (*color)
+ 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)
self.ctx.fill()
@@ -74,7 +75,7 @@ class GerberCairoContext(GerberContext): def _render_rectangle(self, rectangle, color):
ll = map(mul, rectangle.lower_left, self.scale)
width, height = tuple(map(mul, (rectangle.width, rectangle.height), map(abs, self.scale)))
- self.ctx.set_source_rgb (*color)
+ self.ctx.set_source_rgba(*color, alpha=self.alpha)
self.ctx.set_line_width(0)
self.ctx.rectangle(*ll,width=width, height=height)
self.ctx.fill()
|