npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gerber-to-svg

v4.2.8

Published

Render individual Gerber / NC drill files as SVGs

Downloads

2,735

Readme

gerber to svg

latest next david

Render individual Gerber / NC drill files as SVGs

gerber-to-svg is a library and CLI tool for converting Gerber and NC drill files (manufacturing files for printed circuit boards) into SVG files for the web.

Part of the tracespace collection of PCB visualization tools.

install

npm install --save gerber-to-svg
# or
yarn add gerber-to-svg

Or, use a script tag:

<script src="https://unpkg.com/gerber-to-svg@^4.0.0/dist/gerber-to-svg.min.js"></script>
<script>
  // global variable gerberToSvg now available
  var converter = gerberToSvg(input)
</script>

example

After you clone and set-up the repository as detailed in development setup, you can run gerber-to-svg's example script to render all the layers of an Arduino Uno PCB.

cd tracespace/packages/gerber-to-svg
yarn example

arduino uno sol

Arduino Uno design files used here under the terms of the Creative Commons Attribution Share-Alike license.

usage

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

See the API documentation for full details.

command line

If you would like to use gerber-to-svg from the command line, check out @tracespace/cli

background

Since Gerber is a vector image format, this library takes in a Gerber file and spits it out in a different vector format: SVG. This converter uses RS-274X and strives to be true to the latest format specification.

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 1000x 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 need 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.