Giter VIP home page Giter VIP logo

pcb.js's Introduction

pcb.js

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.

Usage

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.

Error handling

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')
  }
});

Styling

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;}

API

pcbjs(config, [options]): function

Parameter Type Description
gerbers Gerber files
options pcb-stackup-core options

gerbers: object

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.

options: object

See pcb-stackup-core docs for more details and additional options

Development

We strongly believe in the power of open source. This module is our way of saying thanks.

If you want to contribute please:

  1. Fork the repository.
  2. Push to your fork and submit a pull request.

Releases

Our releases are created with the help of git-flow.

  1. Create a new release with git flow release start <VERSION>.
  2. Run npm run build-dist.
  3. Bump the version in package.json.
  4. Commit all changes.
  5. Finish the release with git flow release finish <VERSION>.
  6. Push to develop and master and include any tags.
  7. Publish the package to npm with npm publish --access public.

pcb.js's People

Contributors

ju5t avatar kasbah avatar

Stargazers

Aniket_Chauhan avatar ronger avatar

Watchers

James Cloos avatar

pcb.js's Issues

Workaround for incorrectly identified drill file

It should probably be enough to change stackupZip to the following code (and include whats-that-gerber):

function stackupZip(zip) {
  return jszip.loadAsync(zip)
    .then(zip => {
      const files = [];
      zip.forEach((path, file) => {
        if (!file.dir) {
          const layerType = whatsThatGerber(file)
          files.push(
            file
              .async("text")
              .then(contents => ({
                gerber: contents,
                filename: path,
                options: {
                  filetype: (layerType === 'drl') ? 'drill' : 'gerber'
                }
              }))
          );
        }
      });
      return Promise.all(files);
    })
}

Ref:
mcous/gerber-plotter#14 (comment)
mcous/gerber-parser#23

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.