Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gerber-to-svg

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gerber-to-svg

Gerber and NC drill file to SVG converter

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
803
increased by51.8%
Maintainers
1
Weekly downloads
 
Created
Source

gerber-to-svg

Version Build Status Coverage Dependencies DevDependencies

Sauce Test Status

Gerber and NC drill file to SVG converter for Node and the browser.

usage

api

$ npm install --save gerber-to-svg

var gerberToSvg = require('gerber-to-svg')
var converter = gerberToSvg(input, options, [callback])

See the API documentation for full details.

command line

  1. $ npm install -g gerber-to-svg
  2. $ gerber2svg [options] -- gerber_files
options
switchtypehow it rolls
-o, --outstringspecify an output directory
-q, --quietbooleando not print warnings and messages
-p, --prettyintindent output with this length tabs (2 if unspecified)
-c, --colorcoloruse this color instead of "currentColor" for fills and strokes
-f, --formatarrayoverride coordinate format with '[INT,DEC]'
-z, --zerostringoverride zero suppression with 'L' or 'T'
-u, --unitsstringset backup units with 'mm' or 'in'
-n, --notationstringset backup absolute/incremental notation with 'A' or 'I'
-a, --append-extbooleanappend .svg without replacing the existing extension
-v, --versionbooleandisplay version information
-h, --helpbooleandisplay help text
examples:
  • $ gerber2svg gerber.gbr - convert gerber.gbr and output to stdout
  • $ gerber2svg -o out gerber.gbr - convert and output to out/gerber.svg
  • $ gerber2svg -o out -a gerber.gbr - output to out/gerber.gbr.svg

what you get

Since Gerber is just an image format, this library does not attempt to identify nor infer anything about what the file represents (e.g. a copper layer, a silkscreen layer, etc.) It just takes in a Gerber and spits out an SVG. This converter uses RS-274X and strives to be true to the latest format specification. All the Gerber image features should be there.

Everywhere that is "dark" or "exposed" in the Gerber (think a copper trace or a line on the silkscreen) will be "currentColor" in the SVG. You can set this with the "color" CSS property or the "color" attribute in the SVG node itself.

Everywhere that is "clear" (anywhere that was never drawn on or was drawn on but cleared later) will be transparent. This is accomplished though judicious use of SVG masks and groups.

The bounding box is carefully calculated as the file is being converted, so the width and height of the resulting SVG should be nearly (if not exactly) the real world size of the Gerber image. The SVG's viewBox is in Gerber units, so its min-x and min-y values can be used to align SVGs generated from different board layers.

Excellon / NC drill files do not have a completely clearly defined spec, so drill file parsing is lenient in its attempt to generate an image. It should auto-detect when a drill file has been entered. You may have to override parsing settings (see API.md) to get drill files to render properly if they do not adhere to certain assumptions. The library must make these assumptions because Excellon does not define commands for certain formatting decisions.

developing and contributing

Clone and then $ npm install. Please accompany all PRs with applicable tests (unit and/or visual). Please test your code in browsers, as Travis CI cannot run browser tests for PRs.

testing

This module uses Mocha and Chai for unit testing, Istanbul for coverage, and ESLint 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 lint - lint the code (will be run as a pre-commit script)

browser testing

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)

visual testing

The visual test suite made up of sample Gerber files and expected (looks-like) results. Expected SVGs are output from gerbv or hand-coded if the gerbv render is incorrect. Sample files live in test-visual/gerber and expected results live in test-visual/expected.

To run the visual tests, run $ npm run test:visual and point your browser to localhost:4242. Refreshing the page will re-render the files.

Keywords

FAQs

Package last updated on 19 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc