# HG changeset patch # User Robert McIntyre # Date 1283054968 14400 # Node ID db745c95aabd21b8fcfabe633e36f8c47a11dd5c # Parent 397ab24b4952f3b68b37486ace719936eeca4532 trying to revert back to a usable form diff -r 397ab24b4952 -r db745c95aabd src/laser/rasterize.clj --- a/src/laser/rasterize.clj Sun Aug 29 00:03:09 2010 -0400 +++ b/src/laser/rasterize.clj Sun Aug 29 00:09:28 2010 -0400 @@ -181,10 +181,16 @@ ; (vector (first sorted-row) (last sorted-row)))) -(defn row->gcode [[x-dpi y-dpi] row] - (let [[x1 y1] (first row) - [x2 y2] (last row) - x2 (+ x2 (* x-dpi 0.318))] + +(defn row->gcode [[x-dpi y-dpi] forward? row] + + (let [[x1 y1] (if forward? (last row) (first row)) + [x2 y2] (if forward? (first row) (last row))] + + + ; (let [[x1 y1] (first row) +; [x2 y2] (last row) +; x2 (+ x2 (* x-dpi 0.318))] ; (println x2) @@ -237,7 +243,7 @@ (gather-row row))] (let [x (float (* x (/ x-dpi))) y (float (* y (/ x-dpi))) - x (+ x 0.159)];; shift by a small margin. +;; x (+ x 0.159)];; shift by a small margin. (if-not forward? (str (format "0 0 1 %.3f\n" x) (format "0 1 1 %.3f\n" y)) @@ -287,10 +293,17 @@ (defn generate-gcode [pic] (str (raster-preamble) + + (str-join "" + (map + (fn [index row] + (partial row->gcode dpi (even? index)) (indexed (make-rows pic)))) + (raster-epilogue)))) + + - - (str-join "" (map (partial row->gcode dpi) (make-rows pic))) - (raster-epilogue))) +; (str-join "" (map (partial row->gcode dpi) (make-rows pic))) + ; (raster-epilogue)))