diff clojure/com/aurellem/run/basic_choreo.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 96ee9d72aeb9
children 31128a10ee28
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/basic_choreo.clj	Sun Sep 02 06:37:11 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/basic_choreo.clj	Sun Sep 02 09:18:43 2012 -0500
     1.3 @@ -69,6 +69,55 @@
     1.4            (transfer-control image-program-start)
     1.5            (do-nothing 1800))))
     1.6  
     1.7 +(defn basic-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 basic-composite-frames-command
    1.29 +  [move-image screenshot ram-map target]
    1.30 +  ["convert"
    1.31 +   "-size" "318x276" "xc:white"
    1.32 +   move-image   "-geometry" "+30+225" "-composite"
    1.33 +   screenshot   "-geometry" "+10+10"  "-composite"
    1.34 +   ram-map      "-geometry" "+180+10" "-composite"
    1.35 +   target])
    1.36 +
    1.37 +(defn basic-generate-composite-frames!
    1.38 +  [^File rendered-dir]
    1.39 +  (let [final-frames (File. rendered-dir "final")
    1.40 +        _ (.mkdir final-frames)
    1.41 +        move-images (file-names (File. rendered-dir "moves"))
    1.42 +        screenshots (file-names (File. rendered-dir "frames"))
    1.43 +        ram-maps    (file-names (File. rendered-dir "ram-map"))
    1.44 +        targets (map #(.getCanonicalPath
    1.45 +                       (File. final-frames (format "%07d.bmp" %)))
    1.46 +                     (range (count screenshots)))]
    1.47 +    (dorun
    1.48 +     (map
    1.49 +      (comp
    1.50 +       (partial apply clojure.java.shell/sh)
    1.51 +       flatten
    1.52 +       (partial apply basic-composite-frames-command)
    1.53 +       (fn [a b c d] (println d) [a b c d]))
    1.54 +      move-images screenshots ram-maps targets))))
    1.55 +
    1.56  (def basic-render-dir
    1.57    (File. user-home "proj/vba-clojure/render/basic"))
    1.58  
    1.59 @@ -77,10 +126,12 @@
    1.60  (defn basic-step-1! []
    1.61    (render-files!
    1.62     basic-render-dir
    1.63 +   basic-write-move-image!
    1.64 +   true
    1.65     (root) (basic-steps)))
    1.66  
    1.67  (defn basic-step-2! []
    1.68 -  (generate-composite-frames!
    1.69 +  (basic-generate-composite-frames!
    1.70     basic-render-dir))
    1.71  
    1.72  (defn basic-step-3! [] (final-cut! basic-render-dir))