update docs and example images
This commit is contained in:
parent
d9018da412
commit
8c5c7ec8bb
15 changed files with 57 additions and 109 deletions
|
|
@ -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 = {}
|
||||
|
|
@ -100,7 +103,8 @@ class GerberContext(object):
|
|||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ class GerberSvgContext(GerberContext):
|
|||
|
||||
self.apertures = {}
|
||||
self.dwg = svgwrite.Drawing()
|
||||
self.dwg.transform = 'scale 1 -1'
|
||||
self.background = False
|
||||
self.region_path = None
|
||||
|
||||
|
|
@ -124,11 +125,17 @@ class GerberSvgContext(GerberContext):
|
|||
xbounds, ybounds = bounds
|
||||
size = (SCALE * (xbounds[1] - xbounds[0]), SCALE * (ybounds[1] - ybounds[0]))
|
||||
if not self.background:
|
||||
self.dwg = svgwrite.Drawing(viewBox='%f, %f, %f, %f' % (SCALE*xbounds[0], -SCALE*ybounds[1],size[0], size[1]))
|
||||
self.dwg.add(self.dwg.rect(insert=(SCALE * xbounds[0],
|
||||
-SCALE * ybounds[1]),
|
||||
size=size, fill=convert_color(self.background_color)))
|
||||
self.background = True
|
||||
|
||||
def set_alpha(self, alpha):
|
||||
super(GerberSvgContext, self).set_alpha(alpha)
|
||||
import warnings
|
||||
warnings.warn('SVG output does not support transparency')
|
||||
|
||||
def define_aperture(self, d, shape, modifiers):
|
||||
aperture = None
|
||||
if shape == 'C':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue