summaryrefslogtreecommitdiff
path: root/gerber/render/svgwrite_backend.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2014-10-28 22:11:43 -0400
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2014-10-28 22:11:43 -0400
commitf5abd5b0bdc0b9f524456dc9216bd0f3732e82a0 (patch)
tree896c4398f4ee680a63bd8a29b86cee21b95ec836 /gerber/render/svgwrite_backend.py
parentb488ab6af9d7925263b2d0712abfd2ba55dc96d2 (diff)
downloadgerbonara-f5abd5b0bdc0b9f524456dc9216bd0f3732e82a0.tar.gz
gerbonara-f5abd5b0bdc0b9f524456dc9216bd0f3732e82a0.tar.bz2
gerbonara-f5abd5b0bdc0b9f524456dc9216bd0f3732e82a0.zip
Add arc rendering and tests
Diffstat (limited to 'gerber/render/svgwrite_backend.py')
-rw-r--r--gerber/render/svgwrite_backend.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/gerber/render/svgwrite_backend.py b/gerber/render/svgwrite_backend.py
index aeb680c..27783d6 100644
--- a/gerber/render/svgwrite_backend.py
+++ b/gerber/render/svgwrite_backend.py
@@ -18,6 +18,7 @@
from .render import GerberContext
from operator import mul
+import math
import svgwrite
SCALE = 400.
@@ -64,6 +65,19 @@ class GerberSvgContext(GerberContext):
aline.stroke(opacity=self.alpha)
self.dwg.add(aline)
+ def _render_arc(self, arc, color):
+ start = tuple(map(mul, arc.start, self.scale))
+ end = tuple(map(mul, arc.end, self.scale))
+ radius = SCALE * arc.radius
+ width = arc.width if arc.width != 0 else 0.001
+ arc_path = self.dwg.path(d='M %f, %f' % start,
+ stroke=svg_color(color),
+ stroke_width=SCALE * width)
+ large_arc = arc.sweep_angle >= 2 * math.pi
+ direction = '-' if arc.direction == 'clockwise' else '+'
+ arc_path.push_arc(end, 0, radius, large_arc, direction, True)
+ self.dwg.add(arc_path)
+
def _render_region(self, region, color):
points = [tuple(map(mul, point, self.scale)) for point in region.points]
region_path = self.dwg.path(d='M %f, %f' % points[0],