Пример #1
0
a .png file.
"""

import os
from gerber import load_layer, PCB
from gerber.render import RenderSettings, theme
from gerber.render.cairo_backend import GerberCairoContext
from gerber.render.theme import COLORS

GERBER_FOLDER = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'not-working'))

# Create a new drawing context
ctx = GerberCairoContext()

pcb = PCB.from_directory(GERBER_FOLDER, verbose=True)
# Draw the copper layer. render_layer() uses the default color scheme for the
# layer, based on the layer type. Copper layers are rendered as
red_theme = theme.Theme(topmask=RenderSettings(COLORS['red soldermask'],
                                               alpha=0.8,
                                               invert=True),
                        bottommask=RenderSettings(COLORS['red soldermask'],
                                                  alpha=0.8,
                                                  invert=True))

#Rendering layers using the red_theme
ctx.render_layers(layers=pcb.top_layers,
                  filename=os.path.join(
                      os.path.dirname(__file__),
                      'pcb_top_test.png',
                  ),
Пример #2
0
"""

import os
from gerber import PCB
from gerber.render import theme
from gerber.render.cairo_backend import GerberCairoContext


GERBER_FOLDER = os.path.abspath(os.path.join(os.path.dirname(__file__), 'gerbers'))


# Create a new drawing context
ctx = GerberCairoContext()

# Create a new PCB instance
pcb = PCB.from_directory(GERBER_FOLDER)

# Render PCB top view
ctx.render_layers(pcb.top_layers,
                  os.path.join(os.path.dirname(__file__), 'pcb_top.png',),
                  theme.THEMES['OSH Park'], max_width=800, max_height=600)

# Render PCB bottom view
ctx.render_layers(pcb.bottom_layers,
                  os.path.join(os.path.dirname(__file__), 'pcb_bottom.png'),
                  theme.THEMES['OSH Park'], max_width=800, max_height=600)

# Render copper layers only
ctx.render_layers(pcb.copper_layers + pcb.drill_layers,
                  os.path.join(os.path.dirname(__file__),
                               'pcb_transparent_copper.png'),
Пример #3
0
                        if arc.direction == 'counterclockwise':
                            mask.ctx.arc(center[0], center[1], radius, angle1, angle2)
                        else:
                            mask.ctx.arc_negative(center[0], center[1], radius, angle1, angle2)
                    else:
                        mask.ctx.line_to(ll[0], ll[1])
                mask.ctx.set_source_rgba(1.0, 1.0, 1.0, 1.0)
                mask.ctx.fill()
                self.ctx.mask_surface(mask.surface, 0.0, 0.0)
        GerberCairoContext.flatten(self, color, alpha)


###################################################################

# read the gerbers
pcb = PCB.from_directory(gerberPath, None, verbose=True)

outlineTheme = theme.Theme(name='OutlineTheme',
                      background=RenderSettings(theme.COLORS['black'], alpha=0.0),
                      drill=RenderSettings(theme.COLORS['black'], alpha=1.0))
outlineTheme.outline = RenderSettings(theme.COLORS['white'], alpha=1.0)

jlcTheme = theme.Theme(name='JLC',
                      background=RenderSettings(theme.COLORS['fr-4']),
                      top=RenderSettings(theme.COLORS['hasl copper'], alpha=0.85),
                      bottom=RenderSettings(theme.COLORS['hasl copper'], alpha=0.85, mirror=True),
                      topmask=RenderSettings(theme.COLORS['green soldermask'], alpha=0.85, invert=True),
                      bottommask=RenderSettings(theme.COLORS['green soldermask'], alpha=0.85, invert=True, mirror=True),
                      topsilk=RenderSettings(theme.COLORS['white'], alpha=1.0),
                      bottomsilk=RenderSettings(theme.COLORS['white'], alpha=1.0, mirror=True),
                      drill=RenderSettings(theme.COLORS['black'], alpha=1.0))