The code is created to generate g-code file to be used with EggBot, but it can be easily extended to be used for other purpose.
This code converts SVG file to simplified g-code (G0 ang G1 moves only) using nanosvgjs (Zero dependency JavaScript SVG parser based on a translation of the NanoSVG C code) and draws converted g-code on the canvas.
Aditional functionality
Generation of multiple G-code files separated by color for multicolor SVGs
Usage
Load test.html in web browser, click on [Choose file] to load svg image. After loading the SVG if will be automatically parsed and redrawn on the canvas. Click generated image to download g-code
link to nanosvgjs: https://github.com/deanm/nanosvgjs