diff clojure/com/aurellem/run/final_cut.clj @ 599:4503899241e6

going to render the advanced choreo.
author Robert McIntyre <rlm@mit.edu>
date Sun, 02 Sep 2012 09:18:43 -0500
parents 6ce1d5fd4911
children 31128a10ee28
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/final_cut.clj	Sun Sep 02 06:37:11 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/final_cut.clj	Sun Sep 02 09:18:43 2012 -0500
     1.3 @@ -15,29 +15,15 @@
     1.4  
     1.5  (def render-dir (File. user-home "proj/vba-clojure/render/test"))
     1.6  
     1.7 -(defn write-move-image! [move target-file]
     1.8 -  (let [actual-keys (set move)
     1.9 -        keys [:a :b :start :select :u :d :l :r]
    1.10 -        button-on-name  ["-size" "5x5" "xc:red"]
    1.11 -        button-off-name ["-size" "5x5" "xc:white"]]
    1.12 -    (apply
    1.13 -     clojure.java.shell/sh
    1.14 -     (flatten 
    1.15 -      ["convert"
    1.16 -       "-size" "64x5" "xc:white"
    1.17 -       (map
    1.18 -        (fn [index]
    1.19 -          (let [position ["-geometry"
    1.20 -                          (str "+" (* index 8)
    1.21 -                               "+" "0") "-composite"]]
    1.22 -            (if (actual-keys (keys index))
    1.23 -              [button-on-name  position]
    1.24 -              [button-off-name position])))
    1.25 -        (range (count keys)))
    1.26 -       (.getCanonicalPath target-file)]))))
    1.27  
    1.28  (defn render-files!
    1.29 -  ([^File target-dir initial-state moves]
    1.30 +  ([^File target-dir
    1.31 +    moves-render-fn
    1.32 +    render-ram-map?
    1.33 +    initial-state
    1.34 +    moves
    1.35 +    
    1.36 +    ]
    1.37       (let [ram-map-dir (File. target-dir "ram-map")
    1.38             frames-dir (File. target-dir "frames")
    1.39             moves-dir (File. target-dir "moves")
    1.40 @@ -75,7 +61,7 @@
    1.41                     write-video!
    1.42                     (fn [index]
    1.43                       ;; write screenshot
    1.44 -                     (write-move-image!
    1.45 +                     (moves-render-fn
    1.46                        move
    1.47                        (File. moves-dir (format "%07d.png" index)))
    1.48                       
    1.49 @@ -84,9 +70,10 @@
    1.50                        (File. frames-dir (format "%07d.png" index)))
    1.51                       
    1.52                       ;; write ram-image
    1.53 -                     (write-ram-image!
    1.54 -                      @current-state
    1.55 -                      (File. ram-map-dir (format "%07d.png" index))))]
    1.56 +                     (if render-ram-map?
    1.57 +                       (write-ram-image!
    1.58 +                        @current-state
    1.59 +                        (File. ram-map-dir (format "%07d.png" index)))))]
    1.60                 ;;(println "audio-samples:" (count sound))
    1.61                 
    1.62                 ;; record audio
    1.63 @@ -126,33 +113,6 @@
    1.64  (defn file-names [#^File dir]
    1.65     (mapv #(.getCanonicalPath %) (next (sort (file-seq dir)))))
    1.66  
    1.67 -(defn composite-frames-command
    1.68 -  [move-image screenshot ram-map target]
    1.69 -  ["convert"
    1.70 -   "-size" "318x276" "xc:white"
    1.71 -   move-image   "-geometry" "+30+225" "-composite"
    1.72 -   screenshot   "-geometry" "+10+10"  "-composite"
    1.73 -   ram-map      "-geometry" "+180+10" "-composite"
    1.74 -   target])
    1.75 -
    1.76 -(defn generate-composite-frames!
    1.77 -  [^File rendered-dir]
    1.78 -  (let [final-frames (File. rendered-dir "final")
    1.79 -        _ (.mkdir final-frames)
    1.80 -        move-images (file-names (File. rendered-dir "moves"))
    1.81 -        screenshots (file-names (File. rendered-dir "frames"))
    1.82 -        ram-maps    (file-names (File. rendered-dir "ram-map"))
    1.83 -        targets (map #(.getCanonicalPath
    1.84 -                       (File. final-frames (format "%07d.bmp" %)))
    1.85 -                     (range (count screenshots)))]
    1.86 -    (dorun
    1.87 -     (map
    1.88 -      (comp
    1.89 -       (partial apply clojure.java.shell/sh)
    1.90 -       flatten
    1.91 -       (partial apply composite-frames-command)
    1.92 -       (fn [a b c d] (println d) [a b c d]))
    1.93 -      move-images screenshots ram-maps targets))))
    1.94  
    1.95  
    1.96  ;; (defn final-cut! [^File render-dir]