aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoropiopan <opiopan@gmail.com>2019-03-21 22:00:32 +0900
committeropiopan <opiopan@gmail.com>2019-03-21 22:00:32 +0900
commit9febca7da6a730b3b3ca3a54129a9f88e5c44d14 (patch)
tree3f260096ab0c40eca527195630ab004208b4ee78 /test
downloadpcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.gz
pcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.tar.bz2
pcb-tools-extension-9febca7da6a730b3b3ca3a54129a9f88e5c44d14.zip
initial commit
Diffstat (limited to 'test')
-rw-r--r--test/panelimage.py38
-rw-r--r--test/test.py63
2 files changed, 101 insertions, 0 deletions
diff --git a/test/panelimage.py b/test/panelimage.py
new file mode 100644
index 0000000..0636555
--- /dev/null
+++ b/test/panelimage.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+from gerber import load_layer
+from gerber.render import RenderSettings, theme
+from gerber.render.cairo_backend import GerberCairoContext
+
+print('loading ', end='', flush=True)
+copper = load_layer('panelized.GTL')
+print('.', end='', flush=True)
+mask = load_layer('panelized.GTS')
+print('.', end='', flush=True)
+silk = load_layer('panelized.GTO')
+print('.', end='', flush=True)
+drill = load_layer('panelized.TXT')
+print('.', end='', flush=True)
+outline = load_layer('panelized-fill.GML')
+print('.', end='', flush=True)
+print('. end', flush=True)
+
+print('panelizing ', end='', flush=True)
+ctx = GerberCairoContext(scale=30)
+print('.', end='', flush=True)
+ctx.render_layer(copper)
+print('.', end='', flush=True)
+ctx.render_layer(mask)
+print('.', end='', flush=True)
+
+our_settings = RenderSettings(color=theme.COLORS['white'], alpha=0.85)
+ctx.render_layer(silk, settings=our_settings)
+print('.', end='', flush=True)
+
+ctx.render_layer(outline)
+print('.', end='', flush=True)
+ctx.render_layer(drill)
+print('.', end='', flush=True)
+print('. end', flush=True)
+
+print('dumping top...')
+ctx.dump('panelized.png')
diff --git a/test/test.py b/test/test.py
new file mode 100644
index 0000000..d894268
--- /dev/null
+++ b/test/test.py
@@ -0,0 +1,63 @@
+import gerberex
+from gerberex.dxf import DxfFile
+import gerber
+from gerber.render.cairo_backend import GerberCairoContext
+
+def merge():
+ ctx = gerberex.GerberComposition()
+ a = gerberex.read('test.GTL')
+ a.to_metric()
+ ctx.merge(a)
+
+ b = gerberex.read('test.GTL')
+ b.to_metric()
+ b.offset(0, 25)
+ ctx.merge(b)
+
+ c = gerberex.read('test2.GTL')
+ c.to_metric()
+ c.offset(0, 60)
+ ctx.merge(c)
+
+ c = gerberex.read('test.GML')
+ c.to_metric()
+ ctx.merge(c)
+
+ ctx.dump('test-merged.GTL')
+
+def merge2():
+ ctx = gerberex.DrillComposition()
+ a = gerberex.read('test.TXT')
+ a.to_metric()
+ ctx.merge(a)
+
+ b = gerberex.read('test.TXT')
+ b.to_metric()
+ b.offset(0, 25)
+ ctx.merge(b)
+
+ c = gerberex.read('test2.TXT')
+ c.to_metric()
+ c.offset(0, 60)
+ ctx.merge(c)
+
+ ctx.dump('test-merged.TXT')
+
+
+#merge2()
+
+file = gerberex.read('outline.dxf')
+file.to_metric()
+w = file.width
+file.draw_mode = DxfFile.DM_FILL
+file.write('outline.GML')
+
+copper = gerber.load_layer('test-merged.GTL')
+ctx = GerberCairoContext(scale=10)
+ctx.render_layer(copper)
+outline = gerber.load_layer('test.GML')
+outline.cam_source.to_metric()
+ctx.render_layer(outline)
+drill = gerber.load_layer('test-merged.TXT')
+ctx.render_layer(drill)
+ctx.dump('test.png')