コード例 #1
0
def generate_previews(fab_output_path, preview_output_path):
    def read(pattern):
        files = glob(os.path.join(fab_output_path, pattern))
        if not files:
            print "WARNING: Nothing found matching %s" % pattern
            return None
        return load_layer(files[0])

    def save(name):
        path = os.path.join(preview_output_path, "%s.png" % name)
        print "Saving preview to %s" % path
        ctx.dump(path)

    def render(pattern, **kw):
        layer = read(pattern)
        if layer is None:
            print "Not rendering %s" % pattern
            return
        ctx.render_layer(layer, **kw)

    # Rendering context
    ctx = GerberCairoContext(scale=10)
    ctx.color = (80. / 255, 80 / 255., 154 / 255.)
    ctx.drill_color = ctx.color

    # Edges
    render("*.gm1")
    # Copper
    render("*.gtl")
    # Mask
    render("*.gts")
    # Silk
    render("*.gto",
           settings=RenderSettings(color=theme.COLORS['white'], alpha=0.85))
    # Drills
    render("*.drl")

    save("pcb-front")
    ctx.clear()

    # Edges
    render("*.gm1")
    # Copper
    render("*.gbl")
    # Mask
    render("*.gbs")
    # Silk
    render("*.gbo",
           settings=RenderSettings(color=theme.COLORS['white'], alpha=0.85))
    # Drills
    render("*.drl")

    save("pcb-back")
コード例 #2
0

# The default style can be overridden by passing a RenderSettings instance to
# render_layer().
# First, create a settings object:
our_settings = RenderSettings(color=theme.COLORS['white'], alpha=0.85)

# Draw the silkscreen layer, and specify the rendering settings to use
ctx.render_layer(silk, settings=our_settings)

# Draw the drill layer
ctx.render_layer(drill)

# Write output to png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_example.png'))

# Load the bottom layers
copper = load_layer(os.path.join(GERBER_FOLDER, 'bottom_copper.GBL'))
mask = load_layer(os.path.join(GERBER_FOLDER, 'bottom_mask.GBS'))

# Clear the drawing
ctx.clear()

# Render bottom layers
ctx.render_layer(copper)
ctx.render_layer(mask)
ctx.render_layer(drill)

# Write png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_bottom.png'))
コード例 #3
0
ctx.render_layer(mask)

# The default style can be overridden by passing a RenderSettings instance to
# render_layer().
# First, create a settings object:
our_settings = RenderSettings(color=theme.COLORS['white'], alpha=0.85)

# Draw the silkscreen layer, and specify the rendering settings to use
ctx.render_layer(silk, settings=our_settings)

# Draw the drill layer
ctx.render_layer(drill)

# Write output to png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_example.png'))

# Load the bottom layers
copper = load_layer(os.path.join(GERBER_FOLDER, 'bottom_copper.GBL'))
mask = load_layer(os.path.join(GERBER_FOLDER, 'bottom_mask.GBS'))

# Clear the drawing
ctx.clear()

# Render bottom layers
ctx.render_layer(copper)
ctx.render_layer(mask)
ctx.render_layer(drill)

# Write png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_bottom.png'))