Mercurial > cortex
diff org/touch.org @ 185:cfb71209ddc6
moved touch-debug view to touch.org
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 04 Feb 2012 09:33:13 -0700 |
parents | 11bd5f0625ad |
children | 6142e85f5825 |
line wrap: on
line diff
1.1 --- a/org/touch.org Sat Feb 04 09:11:42 2012 -0700 1.2 +++ b/org/touch.org Sat Feb 04 09:33:13 2012 -0700 1.3 @@ -300,6 +300,35 @@ 1.4 (filter #(isa? (class %) Geometry) 1.5 (node-seq creature))))) 1.6 1.7 +(defn gray-scale 1.8 + "Create a gray RGB pixel with R, G, and B set to 'num" 1.9 + [num] 1.10 + (+ num 1.11 + (bit-shift-left num 8) 1.12 + (bit-shift-left num 16))) 1.13 + 1.14 +(defn view-touch 1.15 + "Creates a function which accepts touch sensor-data and displays it 1.16 + as BufferedImages in JFrames." 1.17 + [] 1.18 + (let 1.19 + [windows (atom []) 1.20 + display-single-touch 1.21 + (fn 1.22 + [[coords sensor-data] display] 1.23 + (let [image (points->image coords)] 1.24 + (dorun 1.25 + (for [i (range (count coords))] 1.26 + (.setRGB image ((coords i) 0) ((coords i) 1) 1.27 + (gray-scale (sensor-data i))))) 1.28 + (display image)))] 1.29 + (fn [data] 1.30 + (if (> (count data) (count @windows)) 1.31 + (reset! windows (map (fn [_] (view-image)) 1.32 + (range (count data))))) 1.33 + (dorun (map display-single-touch data @windows))))) 1.34 + 1.35 + 1.36 1.37 #+end_src 1.38