| Package import | "zappem.net/pub/graphics/svgpoly" |
|---|---|
| Documentation | https://pkg.go.dev/zappem.net/pub/graphics/svgpoly |
| Sources | https://github.com/tinkerator/svgpoly |
This package adds support for manipulating a polygon object representation of the content of SVGs. This package is for converting an SVG file input into to a collection of such polygons.
The primary use case is digesting SVG files from KiCad and automating the outline generation of overlapping polygons.
First confirm gnuplot is available on your system. Try:
$ gnuplot --version
If it is missing, install it (Fedora: sudo dnf install gnuplot,
Debian: sudo apt install gnuplot). Then:
$ git clone https://github.com/tinkerator/svgpoly.git
$ cd svgpoly
$ go run examples/outline.go -- --svg examples/test.svg | gnuplot -p
Which should render this processed (union) image:

This is more faithful to the raw input SVG image in terms of the overlapping polygons.
$ go run examples/outline.go --svg examples/test.svg --before --after=false | gnuplot -p
Which should render this image:

Finally, we can inflate the polygons by half of the --scribe width
(--scribe is an indication of how thick the minimal line is when
rendering), simulating where we would actually cut copper, say, to
leave a polygon islands equal to their intended shapes.
$ go run examples/outline.go --svg examples/test.svg --before --scribe 0.3 --inflate | gnuplot -p
Which should render this image:

The svgpoly package is distributed with the same BSD 3-clause
license as that used by
golang itself.
This is a hobby project, so I can’t guarantee a fix, but do use the
github svgpoly bug
tracker.