summaryrefslogtreecommitdiff
path: root/examples/genimage.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-06-06 13:28:42 +0200
committerjaseg <git@jaseg.de>2021-06-06 13:28:42 +0200
commit889ea37d9b66cbfb7a61795c7750b9f4311faa3f (patch)
tree34db36bcdf0501445aaec30c845ed644537e638a /examples/genimage.py
parent5a5ba2b709f01b2100cd767a25a41737541ad53c (diff)
parent71c371ca680483aa9ef18d2998832460dd43abdf (diff)
downloadgerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.tar.gz
gerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.tar.bz2
gerbonara-889ea37d9b66cbfb7a61795c7750b9f4311faa3f.zip
Graft pcb-tools-extension master onto gerbonara main
Diffstat (limited to 'examples/genimage.py')
-rwxr-xr-xexamples/genimage.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/examples/genimage.py b/examples/genimage.py
new file mode 100755
index 0000000..fbb39fb
--- /dev/null
+++ b/examples/genimage.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+import sys, os
+from gerber import load_layer
+from gerber.render import RenderSettings, theme
+from gerber.render.cairo_backend import GerberCairoContext
+
+os.chdir(os.path.dirname(__file__))
+
+def putstr(text):
+ sys.stdout.write(text)
+ sys.stdout.flush()
+
+putstr('loading ')
+copper = load_layer('outputs/panelized.GTL')
+putstr('.')
+mask = load_layer('outputs/panelized.GTS')
+putstr('.')
+silk = load_layer('outputs/panelized.GTO')
+putstr('.')
+drill = load_layer('outputs/panelized.TXT')
+putstr('.')
+outline = load_layer('outputs/panelized-fill.GML')
+putstr('. end\n')
+
+putstr('drawing ')
+ctx = GerberCairoContext(scale=20)
+putstr('.')
+
+metal_settings = RenderSettings(color=(30.0/255.0, 119.0/255.0, 93/255.0))
+bg_settings = RenderSettings(color=(30.0/300.0, 110.0/300.0, 93/300.0))
+ctx.render_layer(copper, settings=metal_settings, bgsettings=bg_settings)
+putstr('.')
+
+copper_settings = RenderSettings(color=(0.7*1.2, 0.5*1.2, 0.1*1.2))
+ctx.render_layer(mask, settings=copper_settings)
+putstr('.')
+
+our_settings = RenderSettings(color=theme.COLORS['white'], alpha=0.80)
+ctx.render_layer(silk, settings=our_settings)
+putstr('.')
+
+ctx.render_layer(outline)
+putstr('.')
+ctx.render_layer(drill)
+putstr('. end\n')
+
+putstr('dumping ... ')
+ctx.dump('outputs/board-top.png')
+putstr('end \n')
+
+ctx.clear()
+putstr('loading bottom ')
+copper = load_layer('outputs/panelized.GBL')
+putstr('.')
+mask = load_layer('outputs/panelized.GBS')
+putstr('.')
+silk = load_layer('outputs/panelized.GBO')
+putstr('. end\n')
+
+putstr('drawing bottom ')
+ctx.render_layer(copper, settings=metal_settings, bgsettings=bg_settings)
+putstr('.')
+ctx.render_layer(mask, settings=copper_settings)
+putstr('.')
+ctx.render_layer(silk, settings=our_settings)
+putstr('.')
+ctx.render_layer(outline)
+putstr('.')
+ctx.render_layer(drill)
+putstr('. end\n')
+
+putstr('dumping bottom ...')
+ctx.dump('outputs/board-bottom.png')
+putstr(' end\n')