Generate beautiful, precise SVG renders of printed circuit boards given a set of Gerber and drill files. Powered by gerber-to-svg and pcb-stackup-core.
Install with:
$ npm install --save pcb-stackup
- viewer.tracespace.io - A Gerber viewer that lets you inspect the individual layers as well as the board preview
- kitnic.it - An electronics project sharing site with links to easily buy the required parts
- OpenHardware.io - A social site around open source hardware. Enables authors to sell and manufacture their boards.
$ git clone https://github.com/tracespace/pcb-stackup
$ cd pcb-stackup && npm install
$ npm run example
The example script builds a render of the Arduino Uno PCB. Arduino Uno design files copyright by Arduino and shared under the terms of a Creative Commons Attribution Share-Alike license (https://www.arduino.cc/en/Main/FAQ).
This module is designed to work in Node or in the browser with Browserify or Webpack. The function takes three parameters: an array of layer objects an optional settings object and a callback function.
var pcbStackup = require('pcb-stackup')
var fs = require('fs')
var fileNames = [
'board-F.Cu.gtl',
'board-F.Mask.gts',
'board-F.SilkS.gto',
'board-F.Paste.gtp',
'board-B.Cu.gbl',
'board-B.Mask.gbs',
'board-B.SilkS.gbo',
'board-B.Paste.gbp',
'board-Edge.Cuts.gm1',
'board.drl',
'board-NPTH.drl'
]
var layers = fileNames.map(function (path) {
return {gerber: fs.createReadStream(path), filename: path}
})
pcbStackup(layers, function (error, stackup) {
if (error) {
throw error
}
console.log(stackup.top.svg) // logs "<svg ... </svg>"
console.log(stackup.bottom.svg) // logs "<svg ... </svg>"
})
If your board doesn't appear at all or looks weirdly distorted try rendering it
with the options {maskWithOutline: false}
or filling in gaps in the outline
with e.g. {outlineGapFill: 0.011}
.
Clone and then $ npm install
. Please accompany all PRs with applicable tests.
Please test your code in browsers, as Travis CI cannot run browser tests for
PRs.
This module uses Mocha and Chai for unit testing, nyc for coverage, and standard for linting.
$ npm test
- run the tests, calculate coverage, and lint$ npm run test:watch
- run the tests on code changes (does not lint nor cover)$ npm run coverage
- print the coverage report of the last test run$ npm run coverage:html
- generate an html report for the last test run$ npm run lint
- lint the code (will be run as a pre-commit script)
The integration tests run the example code on a variety of gerber files to
ensure proper interfacing with gerber-to-svg
and proper rendering of
different stackups.
$ npm run test:integration
- Open http://localhost:8001 in a browser
Browser tests are run with Zuul and Sauce Labs.
$ npm run test:browser
- run the unit tests in a local browser$ npm run test:sauce
- run the units tests in several browsers using Open Sauce (Sauce Labs account and local .zuulrc required)