diff clojure/com/aurellem/run/adv_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 747d47d96d2f
children 31128a10ee28
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))