diff org/test-creature.org @ 114:9d0fe7f54e14

merged image viewing code to cortex.util
author Robert McIntyre <rlm@mit.edu>
date Thu, 19 Jan 2012 22:19:24 -0700
parents 128fa71ee188
children 247860e25536
line wrap: on
line diff
     1.1 --- a/org/test-creature.org	Thu Jan 19 22:08:46 2012 -0700
     1.2 +++ b/org/test-creature.org	Thu Jan 19 22:19:24 2012 -0700
     1.3 @@ -67,34 +67,6 @@
     1.4  (declare joint-create)
     1.5  (use 'clojure.contrib.def)
     1.6  
     1.7 -(defn view-image
     1.8 -  "Initailizes a JPanel on which you may draw a BufferedImage.
     1.9 -   Returns a function that accepts a BufferedImage and draws it to the
    1.10 -   JPanel."
    1.11 -  []
    1.12 -  (let [image
    1.13 -        (atom
    1.14 -         (BufferedImage. 1 1 BufferedImage/TYPE_4BYTE_ABGR))
    1.15 -        panel 
    1.16 -        (proxy [JPanel] []
    1.17 -          (paint
    1.18 -            [graphics]
    1.19 -            (proxy-super paintComponent graphics)
    1.20 -            (.drawImage graphics @image 0 0 nil)))
    1.21 -        frame (JFrame. "Display Image")]
    1.22 -    (SwingUtilities/invokeLater
    1.23 -     (fn []
    1.24 -       (doto frame
    1.25 -         (-> (.getContentPane) (.add panel))
    1.26 -         (.pack)
    1.27 -         (.setLocationRelativeTo nil)
    1.28 -         (.setResizable true)
    1.29 -         (.setVisible true))))
    1.30 -    (fn [#^BufferedImage i]
    1.31 -      (reset! image i)
    1.32 -      (.setSize frame (+ 8 (.getWidth i)) (+ 28 (.getHeight i)))
    1.33 -      (.repaint panel 0 0 (.getWidth i) (.getHeight i)))))
    1.34 -
    1.35  (defn points->image
    1.36    "Take a sparse collection of points and visuliaze it as a
    1.37     BufferedImage."