Mercurial > lasercutter
changeset 14:db745c95aabd
trying to revert back to a usable form
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 29 Aug 2010 00:09:28 -0400 |
parents | 397ab24b4952 |
children | 8ad629298649 |
files | src/laser/rasterize.clj |
diffstat | 1 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/src/laser/rasterize.clj Sun Aug 29 00:03:09 2010 -0400 1.2 +++ b/src/laser/rasterize.clj Sun Aug 29 00:09:28 2010 -0400 1.3 @@ -181,10 +181,16 @@ 1.4 ; (vector (first sorted-row) (last sorted-row)))) 1.5 1.6 1.7 -(defn row->gcode [[x-dpi y-dpi] row] 1.8 - (let [[x1 y1] (first row) 1.9 - [x2 y2] (last row) 1.10 - x2 (+ x2 (* x-dpi 0.318))] 1.11 + 1.12 +(defn row->gcode [[x-dpi y-dpi] forward? row] 1.13 + 1.14 + (let [[x1 y1] (if forward? (last row) (first row)) 1.15 + [x2 y2] (if forward? (first row) (last row))] 1.16 + 1.17 + 1.18 + ; (let [[x1 y1] (first row) 1.19 +; [x2 y2] (last row) 1.20 +; x2 (+ x2 (* x-dpi 0.318))] 1.21 1.22 1.23 ; (println x2) 1.24 @@ -237,7 +243,7 @@ 1.25 (gather-row row))] 1.26 (let [x (float (* x (/ x-dpi))) 1.27 y (float (* y (/ x-dpi))) 1.28 - x (+ x 0.159)];; shift by a small margin. 1.29 +;; x (+ x 0.159)];; shift by a small margin. 1.30 (if-not forward? 1.31 (str (format "0 0 1 %.3f\n" x) 1.32 (format "0 1 1 %.3f\n" y)) 1.33 @@ -287,10 +293,17 @@ 1.34 1.35 (defn generate-gcode [pic] 1.36 (str (raster-preamble) 1.37 + 1.38 + (str-join "" 1.39 + (map 1.40 + (fn [index row] 1.41 + (partial row->gcode dpi (even? index)) (indexed (make-rows pic)))) 1.42 + (raster-epilogue)))) 1.43 + 1.44 + 1.45 1.46 - 1.47 - (str-join "" (map (partial row->gcode dpi) (make-rows pic))) 1.48 - (raster-epilogue))) 1.49 +; (str-join "" (map (partial row->gcode dpi) (make-rows pic))) 1.50 + ; (raster-epilogue))) 1.51 1.52 1.53