pcb.js is a browser implementation of pcb-stackup. It takes both local and remote zip-files as input and converts it to SVG images. We aim to support other sources of input in the future too.
Install with:
$ npm install
or build your own version with the help of browserify
:
npm run build-dist
This will create pcb.js in the dist
folder.
var gerbers = { remote: url };
var options = { id: 'my-board' };
var circuitboard = pcbjs(gerbers, options).then(function process(pcb) {
// pcb contains board_layers, board_width, board_length and the pcb-stackup
// object, e.g. pcb.stackup.top.svg.
}).catch(function(error) {
console.error(error)
});
Choosing your own id helps when styling the output with css.
Errors are part of the Promise return by pcbjs
. For example:
.catch(function(error) {
if (error.message.match(/End of data reached/g)) {
console.error('Incorrect zip file')
}
});
See pcb-stackup-core docs for more details
and additional colour options. Colours can be set in the options
object.
You can also change the colour using css.
layer | classname | example (id = 'my-board') |
---|---|---|
fr4 | id + _fr4 |
.my-board_fr4 {color: #666;} |
cu | id + _cu |
.my-board_cu {color: #ccc;} |
cf | id + _cf |
.my-board_cf {color: #c93;} |
sm | id + _sm |
.my-board_sm {color: #rgba(0, 66, 0, 0.75);} |
ss | id + _ss |
.my-board_ss {color: #fff;} |
sp | id + _sp |
.my-board_sp {color: #999;} |
out | id + _out |
.my-board_out {color: #000;} |
Parameter | Type | Description |
---|---|---|
gerbers | Gerber files | |
options | pcb-stackup-core options |
Name | Type | Default | Description |
---|---|---|---|
remote | string |
Set a remote file to process | |
local | File |
Set a local File to process |
remote
will take precedence over local
.
See pcb-stackup-core docs for more details and additional options
We strongly believe in the power of open source. This module is our way of saying thanks.
If you want to contribute please:
- Fork the repository.
- Push to your fork and submit a pull request.
Our releases are created with the help of git-flow.
- Create a new release with
git flow release start <VERSION>
. - Run
npm run build-dist
. - Bump the version in
package.json
. - Commit all changes.
- Finish the release with
git flow release finish <VERSION>
. - Push to develop and master and include any tags.
- Publish the package to npm with
npm publish --access public
.