changeset 599:4503899241e6

going to render the advanced choreo.
author Robert McIntyre <rlm@mit.edu>
date Sun, 02 Sep 2012 09:18:43 -0500
parents 0b4ff504157d
children 31128a10ee28
files clojure/com/aurellem/run/adv_choreo.clj clojure/com/aurellem/run/basic_choreo.clj clojure/com/aurellem/run/final_cut.clj images/big-button-bar.png images/gb-button-bar.png images/gb-button-mark.png images/gb-yellow.png images/gb-yellow.xcf
diffstat 8 files changed, 125 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/adv_choreo.clj	Sun Sep 02 06:37:11 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/adv_choreo.clj	Sun Sep 02 09:18:43 2012 -0500
     1.3 @@ -341,13 +341,73 @@
     1.4  
     1.5  (defn advanced-steps [] (first (activate-program)))
     1.6  
     1.7 +
     1.8 +(def gb-button-bar
     1.9 +  (File. user-home "/proj/vba-clojure/images/gb-button-bar.png"))
    1.10 +
    1.11 +(def gb-button-mark
    1.12 +  (File. user-home "/proj/vba-clojure/images/gb-button-mark.png"))
    1.13 +
    1.14 +(defn adv-write-move-image! [move target-file]
    1.15 +  (let [buttons (set move)
    1.16 +        key-positions
    1.17 +        {:l [23 23]
    1.18 +         :u [33 11]
    1.19 +         :r [46 23]
    1.20 +         :d [33 26]
    1.21 +         
    1.22 +         :start  [65 24]
    1.23 +         :select [80 24]
    1.24 +
    1.25 +         :b  [100 25]
    1.26 +         :a  [121 25]}]
    1.27 +    (apply
    1.28 +     clojure.java.shell/sh
    1.29 +     (flatten 
    1.30 +      ["convert"
    1.31 +       (.getCanonicalPath gb-button-bar)
    1.32 +       (map
    1.33 +        (fn [key]
    1.34 +          (let [[x y] (key-positions key)]
    1.35 +            (.getCanonicalPath gb-button-mark)
    1.36 +            "-geometry" (str "+" x "+" y) "-composite"))
    1.37 +        buttons)        
    1.38 +       (.getCanonicalPath target-file)]))))
    1.39 +
    1.40 +(defn adv-composite-frames-command
    1.41 +  [move-image screenshot target]
    1.42 +  ["convert"
    1.43 +   screenshot
    1.44 +   move-image "-append"
    1.45 +   target])
    1.46 +
    1.47 +(defn adv-generate-composite-frames!
    1.48 +  [^File rendered-dir]
    1.49 +  (let [final-frames (File. rendered-dir "final")
    1.50 +        _ (.mkdir final-frames)
    1.51 +        move-images (file-names (File. rendered-dir "moves"))
    1.52 +        screenshots (file-names (File. rendered-dir "frames"))
    1.53 +        targets (map #(.getCanonicalPath
    1.54 +                       (File. final-frames (format "%07d.bmp" %)))
    1.55 +                     (range (count screenshots)))]
    1.56 +    (dorun
    1.57 +     (map
    1.58 +      (comp
    1.59 +       (partial apply clojure.java.shell/sh)
    1.60 +       flatten
    1.61 +       (partial apply adv-composite-frames-command)
    1.62 +       (fn [a b  d] (println d) [a b d]))
    1.63 +      move-images screenshots targets))))
    1.64 +
    1.65  (defn advanced-step-1! []
    1.66    (render-files!
    1.67     advanced-render-dir
    1.68 +   adv-write-move-image!
    1.69 +   false
    1.70     (root) (advanced-steps)))
    1.71  
    1.72  (defn advanced-step-2! []
    1.73 -  (generate-composite-frames!
    1.74 +  (adv-generate-composite-frames!
    1.75     advanced-render-dir))
    1.76  
    1.77  (defn advanced-step-3! [] (final-cut! advanced-render-dir))
     2.1 --- a/clojure/com/aurellem/run/basic_choreo.clj	Sun Sep 02 06:37:11 2012 -0500
     2.2 +++ b/clojure/com/aurellem/run/basic_choreo.clj	Sun Sep 02 09:18:43 2012 -0500
     2.3 @@ -69,6 +69,55 @@
     2.4            (transfer-control image-program-start)
     2.5            (do-nothing 1800))))
     2.6  
     2.7 +(defn basic-write-move-image! [move target-file]
     2.8 +  (let [actual-keys (set move)
     2.9 +        keys [:a :b :start :select :u :d :l :r]
    2.10 +        button-on-name  ["-size" "5x5" "xc:red"]
    2.11 +        button-off-name ["-size" "5x5" "xc:white"]]
    2.12 +    (apply
    2.13 +     clojure.java.shell/sh
    2.14 +     (flatten 
    2.15 +      ["convert"
    2.16 +       "-size" "64x5" "xc:white"
    2.17 +       (map
    2.18 +        (fn [index]
    2.19 +          (let [position ["-geometry"
    2.20 +                          (str "+" (* index 8)
    2.21 +                               "+" "0") "-composite"]]
    2.22 +            (if (actual-keys (keys index))
    2.23 +              [button-on-name  position]
    2.24 +              [button-off-name position])))
    2.25 +        (range (count keys)))
    2.26 +       (.getCanonicalPath target-file)]))))
    2.27 +
    2.28 +(defn basic-composite-frames-command
    2.29 +  [move-image screenshot ram-map target]
    2.30 +  ["convert"
    2.31 +   "-size" "318x276" "xc:white"
    2.32 +   move-image   "-geometry" "+30+225" "-composite"
    2.33 +   screenshot   "-geometry" "+10+10"  "-composite"
    2.34 +   ram-map      "-geometry" "+180+10" "-composite"
    2.35 +   target])
    2.36 +
    2.37 +(defn basic-generate-composite-frames!
    2.38 +  [^File rendered-dir]
    2.39 +  (let [final-frames (File. rendered-dir "final")
    2.40 +        _ (.mkdir final-frames)
    2.41 +        move-images (file-names (File. rendered-dir "moves"))
    2.42 +        screenshots (file-names (File. rendered-dir "frames"))
    2.43 +        ram-maps    (file-names (File. rendered-dir "ram-map"))
    2.44 +        targets (map #(.getCanonicalPath
    2.45 +                       (File. final-frames (format "%07d.bmp" %)))
    2.46 +                     (range (count screenshots)))]
    2.47 +    (dorun
    2.48 +     (map
    2.49 +      (comp
    2.50 +       (partial apply clojure.java.shell/sh)
    2.51 +       flatten
    2.52 +       (partial apply basic-composite-frames-command)
    2.53 +       (fn [a b c d] (println d) [a b c d]))
    2.54 +      move-images screenshots ram-maps targets))))
    2.55 +
    2.56  (def basic-render-dir
    2.57    (File. user-home "proj/vba-clojure/render/basic"))
    2.58  
    2.59 @@ -77,10 +126,12 @@
    2.60  (defn basic-step-1! []
    2.61    (render-files!
    2.62     basic-render-dir
    2.63 +   basic-write-move-image!
    2.64 +   true
    2.65     (root) (basic-steps)))
    2.66  
    2.67  (defn basic-step-2! []
    2.68 -  (generate-composite-frames!
    2.69 +  (basic-generate-composite-frames!
    2.70     basic-render-dir))
    2.71  
    2.72  (defn basic-step-3! [] (final-cut! basic-render-dir))
     3.1 --- a/clojure/com/aurellem/run/final_cut.clj	Sun Sep 02 06:37:11 2012 -0500
     3.2 +++ b/clojure/com/aurellem/run/final_cut.clj	Sun Sep 02 09:18:43 2012 -0500
     3.3 @@ -15,29 +15,15 @@
     3.4  
     3.5  (def render-dir (File. user-home "proj/vba-clojure/render/test"))
     3.6  
     3.7 -(defn write-move-image! [move target-file]
     3.8 -  (let [actual-keys (set move)
     3.9 -        keys [:a :b :start :select :u :d :l :r]
    3.10 -        button-on-name  ["-size" "5x5" "xc:red"]
    3.11 -        button-off-name ["-size" "5x5" "xc:white"]]
    3.12 -    (apply
    3.13 -     clojure.java.shell/sh
    3.14 -     (flatten 
    3.15 -      ["convert"
    3.16 -       "-size" "64x5" "xc:white"
    3.17 -       (map
    3.18 -        (fn [index]
    3.19 -          (let [position ["-geometry"
    3.20 -                          (str "+" (* index 8)
    3.21 -                               "+" "0") "-composite"]]
    3.22 -            (if (actual-keys (keys index))
    3.23 -              [button-on-name  position]
    3.24 -              [button-off-name position])))
    3.25 -        (range (count keys)))
    3.26 -       (.getCanonicalPath target-file)]))))
    3.27  
    3.28  (defn render-files!
    3.29 -  ([^File target-dir initial-state moves]
    3.30 +  ([^File target-dir
    3.31 +    moves-render-fn
    3.32 +    render-ram-map?
    3.33 +    initial-state
    3.34 +    moves
    3.35 +    
    3.36 +    ]
    3.37       (let [ram-map-dir (File. target-dir "ram-map")
    3.38             frames-dir (File. target-dir "frames")
    3.39             moves-dir (File. target-dir "moves")
    3.40 @@ -75,7 +61,7 @@
    3.41                     write-video!
    3.42                     (fn [index]
    3.43                       ;; write screenshot
    3.44 -                     (write-move-image!
    3.45 +                     (moves-render-fn
    3.46                        move
    3.47                        (File. moves-dir (format "%07d.png" index)))
    3.48                       
    3.49 @@ -84,9 +70,10 @@
    3.50                        (File. frames-dir (format "%07d.png" index)))
    3.51                       
    3.52                       ;; write ram-image
    3.53 -                     (write-ram-image!
    3.54 -                      @current-state
    3.55 -                      (File. ram-map-dir (format "%07d.png" index))))]
    3.56 +                     (if render-ram-map?
    3.57 +                       (write-ram-image!
    3.58 +                        @current-state
    3.59 +                        (File. ram-map-dir (format "%07d.png" index)))))]
    3.60                 ;;(println "audio-samples:" (count sound))
    3.61                 
    3.62                 ;; record audio
    3.63 @@ -126,33 +113,6 @@
    3.64  (defn file-names [#^File dir]
    3.65     (mapv #(.getCanonicalPath %) (next (sort (file-seq dir)))))
    3.66  
    3.67 -(defn composite-frames-command
    3.68 -  [move-image screenshot ram-map target]
    3.69 -  ["convert"
    3.70 -   "-size" "318x276" "xc:white"
    3.71 -   move-image   "-geometry" "+30+225" "-composite"
    3.72 -   screenshot   "-geometry" "+10+10"  "-composite"
    3.73 -   ram-map      "-geometry" "+180+10" "-composite"
    3.74 -   target])
    3.75 -
    3.76 -(defn generate-composite-frames!
    3.77 -  [^File rendered-dir]
    3.78 -  (let [final-frames (File. rendered-dir "final")
    3.79 -        _ (.mkdir final-frames)
    3.80 -        move-images (file-names (File. rendered-dir "moves"))
    3.81 -        screenshots (file-names (File. rendered-dir "frames"))
    3.82 -        ram-maps    (file-names (File. rendered-dir "ram-map"))
    3.83 -        targets (map #(.getCanonicalPath
    3.84 -                       (File. final-frames (format "%07d.bmp" %)))
    3.85 -                     (range (count screenshots)))]
    3.86 -    (dorun
    3.87 -     (map
    3.88 -      (comp
    3.89 -       (partial apply clojure.java.shell/sh)
    3.90 -       flatten
    3.91 -       (partial apply composite-frames-command)
    3.92 -       (fn [a b c d] (println d) [a b c d]))
    3.93 -      move-images screenshots ram-maps targets))))
    3.94  
    3.95  
    3.96  ;; (defn final-cut! [^File render-dir]
     4.1 Binary file images/big-button-bar.png has changed
     5.1 Binary file images/gb-button-bar.png has changed
     6.1 Binary file images/gb-button-mark.png has changed
     7.1 Binary file images/gb-yellow.png has changed
     8.1 Binary file images/gb-yellow.xcf has changed