summaryrefslogtreecommitdiff
path: root/gerber/render/render.py
diff options
context:
space:
mode:
authorHamilton Kibbe <ham@hamiltonkib.be>2014-10-13 12:38:57 -0400
committerHamilton Kibbe <ham@hamiltonkib.be>2014-10-13 12:38:57 -0400
commit6adcdbae5fc06959203761616e778ba4594475cc (patch)
tree1b878d7fe63645899a0d631849596b70bd002b07 /gerber/render/render.py
parent152fca07685d6f96f5e5bad723f1f62de99d8b7d (diff)
parent8c5c7ec8bbc8a074884ef04b566f9c0ecd6e78bb (diff)
downloadgerbonara-6adcdbae5fc06959203761616e778ba4594475cc.tar.gz
gerbonara-6adcdbae5fc06959203761616e778ba4594475cc.tar.bz2
gerbonara-6adcdbae5fc06959203761616e778ba4594475cc.zip
Merge branch 'master' of https://github.com/hamiltonkibbe/gerber-tools
Diffstat (limited to 'gerber/render/render.py')
-rw-r--r--gerber/render/render.py42
1 files changed, 33 insertions, 9 deletions
diff --git a/gerber/render/render.py b/gerber/render/render.py
index e76aed1..f7e4485 100644
--- a/gerber/render/render.py
+++ b/gerber/render/render.py
@@ -83,6 +83,9 @@ class GerberContext(object):
background_color : tuple (<float>, <float>, <float>)
Color of the background. Used when exposing areas in 'clear' level
polarity mode. Format is the same as for `color`.
+
+ alpha : float
+ Rendering opacity. Between 0.0 (transparent) and 1.0 (opaque.)
"""
def __init__(self):
self.settings = {}
@@ -96,11 +99,12 @@ class GerberContext(object):
self.level_polarity = 'dark'
self.region_mode = 'off'
self.quadrant_mode = 'multi-quadrant'
-
+ self.step_and_repeat = (1, 1, 0, 0)
self.color = (0.7215, 0.451, 0.200)
self.drill_color = (0.25, 0.25, 0.25)
self.background_color = (0.0, 0.0, 0.0)
-
+ self.alpha = 1.0
+
def set_format(self, settings):
""" Set source file format.
@@ -260,6 +264,19 @@ class GerberContext(object):
"""
self.background_color = color
+ def set_alpha(self, alpha):
+ """ Set layer rendering opacity
+
+ .. note::
+ Not all backends/rendering devices support this parameter.
+
+ Parameters
+ ----------
+ alpha : float
+ Rendering opacity. must be between 0.0 (transparent) and 1.0 (opaque)
+ """
+ self.alpha = alpha
+
def resolve(self, x, y):
""" Resolve missing x or y coordinates in a coordinate command.
@@ -415,6 +432,12 @@ class GerberContext(object):
"""
pass
+ def region_contour(self, x, y):
+ pass
+
+ def fill_region(self):
+ pass
+
def evaluate(self, stmt):
""" Evaluate Gerber statement and update image accordingly.
@@ -450,7 +473,7 @@ class GerberContext(object):
def _evaluate_mode(self, stmt):
if stmt.type == 'RegionMode':
if self.region_mode == 'on' and stmt.mode == 'off':
- self._fill_region()
+ self.fill_region()
self.region_mode = stmt.mode
elif stmt.type == 'QuadrantMode':
self.quadrant_mode = stmt.mode
@@ -460,11 +483,11 @@ class GerberContext(object):
self.set_coord_format(stmt.zero_suppression, stmt.format,
stmt.notation)
self.set_coord_notation(stmt.notation)
- elif stmt.param == "MO:":
+ elif stmt.param == "MO":
self.set_coord_unit(stmt.mode)
- elif stmt.param == "IP:":
+ elif stmt.param == "IP":
self.set_image_polarity(stmt.ip)
- elif stmt.param == "LP:":
+ elif stmt.param == "LP":
self.set_level_polarity(stmt.lp)
elif stmt.param == "AD":
self.define_aperture(stmt.d, stmt.shape, stmt.modifiers)
@@ -477,7 +500,10 @@ class GerberContext(object):
self.direction = ('clockwise' if stmt.function in ('G02', 'G2')
else 'counterclockwise')
if stmt.op == "D01":
- self.stroke(stmt.x, stmt.y, stmt.i, stmt.j)
+ if self.region_mode == 'on':
+ self.region_contour(stmt.x, stmt.y)
+ else:
+ self.stroke(stmt.x, stmt.y, stmt.i, stmt.j)
elif stmt.op == "D02":
self.move(stmt.x, stmt.y)
elif stmt.op == "D03":
@@ -486,5 +512,3 @@ class GerberContext(object):
def _evaluate_aperture(self, stmt):
self.set_aperture(stmt.d)
- def _fill_region(self):
- pass