juicy-gcode: SVG to G-Code converter

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

SVG to G-code converter that aims to support most SVG features. The flavor of the generated G-Code can be influenced providing a configuration file.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.5.1, 0.1.0.5.2, 0.1.0.6, 0.1.0.7, 0.1.0.8, 0.1.0.9, 0.1.0.10, 0.1.0.10, 0.2.0.1, 0.2.0.2, 0.2.1.0, 0.3.0.0, 1.0.0.0
Change log ChangeLog.md
Dependencies base (>=4.8 && <5), configurator (>=0.3 && <0.4), lens (>=4.15.4 && <4.20), linear (>=1.20 && <1.22), matrix (>=0.3.5 && <0.4), optparse-applicative (>=0.13 && <0.16), svg-tree (>=0.6 && <0.7), text (>=1.2.2 && <1.3) [details]
License BSD-3-Clause
Author dlacko
Maintainer dlacko@gmail.com
Category Graphics
Home page https://github.com/domoszlai/juicy-gcode
Bug tracker https://github.com/domoszlai/juicy-gcode/issues
Source repo head: git clone https://github.com/domoszlai/juicy-gcode
Uploaded by dlacko at 2020-08-19T09:29:10Z

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for juicy-gcode-0.1.0.10

[back to package description]

Juicy-gcode: A lightweight SVG to GCode converter for maximal curve fitting

Hackage Travis Appveyor

Overview

Haskell SVG to G-code converter that aims to support most SVG features. The flavor of the generated G-Code can be influenced providing a configuration file. Juicy-gcode, in contrast to most SVG to G-Code converters, approximates bezier curves with biarcs instead of line segments that results in much better curve fit.

Installation and usage

The easiest way is to download one of the pre-built binaries from the releases page. Alternatively, you can build from source code as follows:

juicy-gcode - The SVG to G-Code converter

Usage: juicy-gcode SVGFILE [-f|--flavor CONFIGFILE] [-o|--output OUTPUTFILE]
                   [-d|--dpi DPI] [-r|--resolution RESOLUTION]
                   [-m|--mirror-y-axis] [-b|--generate-bezier]
  Convert SVGFILE to G-Code

Available options:
  -h,--help                   Show this help text
  SVGFILE                     The SVG file to be converted
  -f,--flavor CONFIGFILE      Configuration of G-Code flavor
  -o,--output OUTPUTFILE      The output G-Code file (default is standard output)
  -d,--dpi DPI                Used to determine the size of the SVG when it does
                              not contain any units; dot per inch (default is 72)
  -r,--resolution RESOLUTION  Shorter paths are replaced by line segments; mm
                              (default is 0.1)
  -m,--mirror-y-axis          Mirror Y axis to have the result in G-Code coordinate
                              system
  -b,--generate-bezier        Generate bezier curves (G5) instead of arcs (G2,G3)

Configuration

The default G-Code flavor configuration file is the following:

gcode
{
   begin = "G17;G90;G0 Z10;G0 X0 Y0;M3;G4 P2000.000000"
   end = "G0 Z10;M5;M2"
   toolon =  "G00 Z10"
   tooloff = "G01 Z0 F10.00"
}

A new configuration file can be set by the --flavor or -f command line option.

Another configurable property is the resolution of the SVG image in DPI (dot per inch). It can be given by the --dpi or -d command line option. Default value is 72 DPI.

Limitations

Missing features:

Testing and bugs

There is a JavaScript hanging plotter simulator mainly developed to test the generated gcode. Please file an issue if you run into a problem (or drop me an email to dlacko @ gmail.com).

Implementation

SVG images are built using the following shapes (all of these are subject of an arbitrary affine transformation):

In contrast G-Code implements only

That means that only lines, circles and some arcs (non-elliptic ones without rotation) can be translated to G-Code directly. If transformations are also counted, then only lines can be translated to G-Code directly as circles are not invariant under affine transformations. Because of this, the converter is implemented in two stages.

Stage 1

All the SVG drawing operations are translated to a list of MoveTo, LineTo and CubicBezierTo operations as these are invariant under affine transformations. Arcs, circles and ellipses can be easily approximated with bezier curves with a small error.

Stage 2

Cubic bezier curves are approximated with Biarcs using the algorithm described in [1] and explained here.