comparison 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
comparison
equal deleted inserted replaced
598:0b4ff504157d 599:4503899241e6
67 ([script] 67 ([script]
68 (->> script 68 (->> script
69 (transfer-control image-program-start) 69 (transfer-control image-program-start)
70 (do-nothing 1800)))) 70 (do-nothing 1800))))
71 71
72 (defn basic-write-move-image! [move target-file]
73 (let [actual-keys (set move)
74 keys [:a :b :start :select :u :d :l :r]
75 button-on-name ["-size" "5x5" "xc:red"]
76 button-off-name ["-size" "5x5" "xc:white"]]
77 (apply
78 clojure.java.shell/sh
79 (flatten
80 ["convert"
81 "-size" "64x5" "xc:white"
82 (map
83 (fn [index]
84 (let [position ["-geometry"
85 (str "+" (* index 8)
86 "+" "0") "-composite"]]
87 (if (actual-keys (keys index))
88 [button-on-name position]
89 [button-off-name position])))
90 (range (count keys)))
91 (.getCanonicalPath target-file)]))))
92
93 (defn basic-composite-frames-command
94 [move-image screenshot ram-map target]
95 ["convert"
96 "-size" "318x276" "xc:white"
97 move-image "-geometry" "+30+225" "-composite"
98 screenshot "-geometry" "+10+10" "-composite"
99 ram-map "-geometry" "+180+10" "-composite"
100 target])
101
102 (defn basic-generate-composite-frames!
103 [^File rendered-dir]
104 (let [final-frames (File. rendered-dir "final")
105 _ (.mkdir final-frames)
106 move-images (file-names (File. rendered-dir "moves"))
107 screenshots (file-names (File. rendered-dir "frames"))
108 ram-maps (file-names (File. rendered-dir "ram-map"))
109 targets (map #(.getCanonicalPath
110 (File. final-frames (format "%07d.bmp" %)))
111 (range (count screenshots)))]
112 (dorun
113 (map
114 (comp
115 (partial apply clojure.java.shell/sh)
116 flatten
117 (partial apply basic-composite-frames-command)
118 (fn [a b c d] (println d) [a b c d]))
119 move-images screenshots ram-maps targets))))
120
72 (def basic-render-dir 121 (def basic-render-dir
73 (File. user-home "proj/vba-clojure/render/basic")) 122 (File. user-home "proj/vba-clojure/render/basic"))
74 123
75 (defn basic-steps [] (first (activate-media))) 124 (defn basic-steps [] (first (activate-media)))
76 125
77 (defn basic-step-1! [] 126 (defn basic-step-1! []
78 (render-files! 127 (render-files!
79 basic-render-dir 128 basic-render-dir
129 basic-write-move-image!
130 true
80 (root) (basic-steps))) 131 (root) (basic-steps)))
81 132
82 (defn basic-step-2! [] 133 (defn basic-step-2! []
83 (generate-composite-frames! 134 (basic-generate-composite-frames!
84 basic-render-dir)) 135 basic-render-dir))
85 136
86 (defn basic-step-3! [] (final-cut! basic-render-dir)) 137 (defn basic-step-3! [] (final-cut! basic-render-dir))