Package import"zappem.net/pub/graphics/svgpoly"
Documentationhttps://pkg.go.dev/zappem.net/pub/graphics/svgpoly
Sourceshttps://github.com/tinkerator/svgpoly

svgpoly is a package to support SVG to polygon conversion

Overview

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.

How to use

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:

polygon outlines of shapes

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:

More raw SVG input

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:

Inflated union

License info

The svgpoly package is distributed with the same BSD 3-clause license as that used by golang itself.

Reporting bugs

This is a hobby project, so I can’t guarantee a fix, but do use the github svgpoly bug tracker.


Markdown rendering courtesy of gomarkdown/markdown.