# HG changeset patch # User Robert McIntyre # Date 1326114329 25200 # Node ID e70ec4bba96b073b75aa2b76406f1cafa3abc36b # Parent 2bcc7636cfeac6390432e774d6d5bdf5cecac23c saving progress... diff -r 2bcc7636cfea -r e70ec4bba96b assets/Models/creature1/try-again.blend Binary file assets/Models/creature1/try-again.blend has changed diff -r 2bcc7636cfea -r e70ec4bba96b org/test-creature.org --- a/org/test-creature.org Mon Jan 09 06:02:06 2012 -0700 +++ b/org/test-creature.org Mon Jan 09 06:05:29 2012 -0700 @@ -378,15 +378,11 @@ (frame [image+] (frame (.getBufferedImage image+)))) -(defn rgb->int [r g b] - (+ (bit-shift-left r 16) - (bit-shift-left g 8) - b)) - - +(def white -1) (defn filter-pixels "List the coordinates of all pixels matching pred." + {:author "Dylan Holmes"} [pred #^ImageProcessor ip] (let [width (.getWidth ip) @@ -400,109 +396,11 @@ :else (recur (inc x) y matches))) 0 0 []))) - - - - -(defn filter-pixels* - [pred #^ImageProcessor ip] - (let - [width (.getWidth ip) - height (.getHeight ip) - coords (ref []) - process - (fn [[start end]] - (loop [i start] - (if (<= i end) - (do - (let [column (rem i height) - row (unchecked-divide i width)] - (if (pred (.getPixel ip row column)) - (dosync (ref-set - coords - (conj @coords (Vector2f. column row))))) - - (recur (inc i))))))) - ] - - - (dorun - (pmap process (partition - 2 - (conj (vec (range 0 (* width height) 100)) - (* width height))))) - @coords)) - - - -(comment - ((-> - f - (partial x) - (partial y) - (partial z)))) - -(defn filter-pixels** - [pred #^ImageProcessor ip] - (let [width (.getWidth ip) - height (.getHeight ip)] - ((fn f [x1 x2 y1 y2] - (println x1) - (if - (and - (= x1 (dec x2)) - (= y1 (dec y2))) - (if (pred (.getPixel ip x1 y1)) - [[x1 y1]] - []) - (let - [xm (+ x1 (/ (- x2 x1) 2)) - ym (+ y1 (/ (- y2 y1) 2))] - (apply concat - (pvalues - ;;(f x1 xm y1 ym) - ;;(f xm x2 y1 ym) - ;;(f x1 xm ym y2) - (f xm x2 ym y2)))))) - 0 width 0 height))) - - - - - - - - -(defn white-coordinates* - [#^ImageProcessor ip] - (filter-pixels** #(== % -1) ip)) - - (defn white-coordinates "List the coordinates of all the white pixels in an image." [#^ImageProcessor ip] - (let [height (.getHeight ip) - width (.getWidth ip) - coords (transient [])] - (dorun - (for [x (range width) - y (range height)] - (let [pixel (.getPixel ip x y)] - (if (= pixel -1) - (conj! coords (Vector2f. x y)))))) - (persistent! coords))) - - - - - - + (filter-pixels #(= % white) ip)) - -(def white {:r 255, :g 255, :b 255}) -(def black {:r 0, :g 0, :b 0}) - - (defn same-side? [p1 p2 ref p] (<= 0