packages feed

juicy-gcode 0.1.0.1 → 0.1.0.2

raw patch · 4 files changed

+92/−82 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for juicy-gcode
 
+## 0.1.0.2  -- 2017-03-18
+
+* Fix generating arcs with negative I or J
+
 ## 0.1.0.1  -- 2016-10-31
 
 * Minor changes to the package description and README.
GCode.hs view
@@ -38,7 +38,8 @@                 cmd = if' cw "G03" "G02" 
             
                 arcStr 
-                    | (mm i) < 1 || (mm i) < 1
+                    -- avoid tiny arcs
+                    | (mm $ abs i) < 1 && (mm $ abs j) < 1
                         = printf "G01 X%.4f Y%.4f" (mm x) (mm y)
                     | otherwise 
                         = printf "%s X%.4f Y%.4f I%.4f J%.4f" cmd (mm x) (mm y) (mm i) (mm j)
README.md view
@@ -1,79 +1,84 @@-## Synopsis--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.--## Installation and usage--* Install the latest [Haskell Platform](https://www.haskell.org/platform/) if you do not have it yet-* `$ git clone https://github.com/domoszlai/juicy-gcode.git`-* `$ cabal install juicy-gcode/juicy-gcode.cabal`-* `$ juicy-gcode --help`--```-juicy-gcode - The SVG to G-Code converter--Usage: juicy-gcode.exe SVGFILE [-f|--flavor CONFIGFILE] [-o|--output OUTPUTFILE]-                       [-d|--dpi DPI]-  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             Density of the SVG file (default is 72 DPI)-```--## 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:-* text (easy with e.g. [FontyFruity](https://hackage.haskell.org/package/FontyFruity), maybe once, you can convert text to curves easily anyway)-* filling (moderately difficult)-* clipping (probably not easy, maybe once)-* images (not planned)--## Implementation--SVG images are built using the following shapes (all of these are subject of an arbitrary affine transformation):--* lines-* circles-* ellipses-* elliptic arcs with optional x axis rotation-* quadratic and cubic bezier curves  -  -In contrast G-Code implements only   -  -* lines -* non-elliptical arcs    --That means that only lines, circles and some arcs (non-elliptic ones without rotation) can be transleted 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](https://en.wikipedia.org/wiki/Biarc) using the algorithm described in [[1](http://www.itc.ktu.lt/index.php/ITC/article/view/11812)] and explained [here](http://dlacko.blogspot.nl/2016/10/approximating-bezier-curves-by-biarcs.html).-+## Synopsis
+
+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.
+
+## Installation and usage
+
+* Install the latest [Haskell Platform](https://www.haskell.org/platform/) if you do not have it yet
+* `$ git clone https://github.com/domoszlai/juicy-gcode.git`
+* `$ cabal install juicy-gcode/juicy-gcode.cabal`
+* `$ juicy-gcode --help`
+
+```
+juicy-gcode - The SVG to G-Code converter
+
+Usage: juicy-gcode.exe SVGFILE [-f|--flavor CONFIGFILE] [-o|--output OUTPUTFILE]
+                       [-d|--dpi DPI]
+  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             Density of the SVG file (default is 72 DPI)
+```
+
+## 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:
+* text (easy with e.g. [FontyFruity](https://hackage.haskell.org/package/FontyFruity), maybe once, you can convert text to curves easily anyway)
+* filling (moderately difficult)
+* clipping (probably not easy, maybe once)
+* images (not planned)
+
+## Testing and bugs
+
+There is a JavaScript [hanging plotter simulator](https://github.com/domoszlai/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):
+
+* lines
+* circles
+* ellipses
+* elliptic arcs with optional x axis rotation
+* quadratic and cubic bezier curves  
+  
+In contrast G-Code implements only   
+  
+* lines 
+* non-elliptical arcs    
+
+That means that only lines, circles and some arcs (non-elliptic ones without rotation) can be transleted 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](https://en.wikipedia.org/wiki/Biarc) using the algorithm described in [[1](http://www.itc.ktu.lt/index.php/ITC/article/view/11812)] and explained [here](http://dlacko.blogspot.nl/2016/10/approximating-bezier-curves-by-biarcs.html).
+
juicy-gcode.cabal view
@@ -1,5 +1,5 @@ name:                juicy-gcode
-version:             0.1.0.1
+version:             0.1.0.2
 license:             BSD3
 license-file:        LICENSE
 author:              dlacko
@@ -20,7 +20,7 @@ 
   other-modules:       Approx BiArc CircularArc CubiCBezier GCode Line Render SvgArcSegment Transformation Types
     
-  build-depends:       base >=4.9 && <4.10, svg-tree >=0.5 && <0.6, matrix >=0.3 && <0.4,text >=1.2 && <1.3, configurator >=0.3 && <0.4, optparse-applicative >=0.13 && <0.14, linear >=1.20 && <1.21, lens >=4.14 && <4.15
+  build-depends:       base >=4.8 && <4.10, svg-tree >=0.5 && <0.6, matrix >=0.3 && <0.4,text >=1.2 && <1.3, configurator >=0.3 && <0.4, optparse-applicative >=0.13 && <0.14, linear >=1.20 && <1.21, lens >=4.14 && <4.15
 
   GHC-Options: -Wall
   default-language: Haskell2010