summaryrefslogtreecommitdiff
path: root/gerber/render/cairo_backend.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hkibbe@entic.com>2018-06-05 08:57:37 -0400
committerHamilton Kibbe <hkibbe@entic.com>2018-06-05 08:57:37 -0400
commit5245fb925684b4ebe056e6509bfeca6b167903b5 (patch)
tree56615e66b5a9a2b3e04cf58b0b94604bac7af3f4 /gerber/render/cairo_backend.py
parent31062ba2ce326bf3165c15b325b31b226dc69a11 (diff)
downloadgerbonara-5245fb925684b4ebe056e6509bfeca6b167903b5.tar.gz
gerbonara-5245fb925684b4ebe056e6509bfeca6b167903b5.tar.bz2
gerbonara-5245fb925684b4ebe056e6509bfeca6b167903b5.zip
Fix hard requirement of cairo per #83, and add stubs for required subclass methods to GerberContext per #84
Diffstat (limited to 'gerber/render/cairo_backend.py')
-rw-r--r--gerber/render/cairo_backend.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 0e3a721..e1d1408 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -91,7 +91,7 @@ class GerberCairoContext(GerberContext):
self.set_bounds(bounds)
else:
self.set_bounds(layer.bounds)
- self._paint_background(bgsettings)
+ self.paint_background(bgsettings)
if verbose:
print('[Render]: Rendering {} Layer.'.format(layer.layer_class))
self._render_count += 1
@@ -193,11 +193,11 @@ class GerberCairoContext(GerberContext):
def _render_layer(self, layer, settings):
self.invert = settings.invert
# Get a new clean layer to render on
- self._new_render_layer(mirror=settings.mirror)
+ self.new_render_layer(mirror=settings.mirror)
for prim in layer.primitives:
self.render(prim)
# Add layer to image
- self._flatten(settings.color, settings.alpha)
+ self.flatten(settings.color, settings.alpha)
def _render_line(self, line, color):
start = self.scale_point(line.start)
@@ -530,7 +530,7 @@ class GerberCairoContext(GerberContext):
self.ctx.show_text(primitive.net_name)
self.ctx.scale(1, -1)
- def _new_render_layer(self, color=None, mirror=False):
+ def new_render_layer(self, color=None, mirror=False):
size_in_pixels = self.scale_point(self.size_in_inch)
matrix = copy.copy(self._xform_matrix)
layer = cairo.SVGSurface(None, size_in_pixels[0], size_in_pixels[1])
@@ -548,8 +548,7 @@ class GerberCairoContext(GerberContext):
self.active_layer = layer
self.active_matrix = matrix
-
- def _flatten(self, color=None, alpha=None):
+ def flatten(self, color=None, alpha=None):
color = color if color is not None else self.color
alpha = alpha if alpha is not None else self.alpha
self.output_ctx.set_source_rgba(color[0], color[1], color[2], alpha)
@@ -558,7 +557,7 @@ class GerberCairoContext(GerberContext):
self.active_layer = None
self.active_matrix = None
- def _paint_background(self, settings=None):
+ def paint_background(self, settings=None):
color = settings.color if settings is not None else self.background_color
alpha = settings.alpha if settings is not None else 1.0
if not self.has_bg: