comparison 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
comparison
equal deleted inserted replaced
598:0b4ff504157d 599:4503899241e6
339 (def advanced-render-dir 339 (def advanced-render-dir
340 (File. user-home "proj/vba-clojure/render/advanced")) 340 (File. user-home "proj/vba-clojure/render/advanced"))
341 341
342 (defn advanced-steps [] (first (activate-program))) 342 (defn advanced-steps [] (first (activate-program)))
343 343
344
345 (def gb-button-bar
346 (File. user-home "/proj/vba-clojure/images/gb-button-bar.png"))
347
348 (def gb-button-mark
349 (File. user-home "/proj/vba-clojure/images/gb-button-mark.png"))
350
351 (defn adv-write-move-image! [move target-file]
352 (let [buttons (set move)
353 key-positions
354 {:l [23 23]
355 :u [33 11]
356 :r [46 23]
357 :d [33 26]
358
359 :start [65 24]
360 :select [80 24]
361
362 :b [100 25]
363 :a [121 25]}]
364 (apply
365 clojure.java.shell/sh
366 (flatten
367 ["convert"
368 (.getCanonicalPath gb-button-bar)
369 (map
370 (fn [key]
371 (let [[x y] (key-positions key)]
372 (.getCanonicalPath gb-button-mark)
373 "-geometry" (str "+" x "+" y) "-composite"))
374 buttons)
375 (.getCanonicalPath target-file)]))))
376
377 (defn adv-composite-frames-command
378 [move-image screenshot target]
379 ["convert"
380 screenshot
381 move-image "-append"
382 target])
383
384 (defn adv-generate-composite-frames!
385 [^File rendered-dir]
386 (let [final-frames (File. rendered-dir "final")
387 _ (.mkdir final-frames)
388 move-images (file-names (File. rendered-dir "moves"))
389 screenshots (file-names (File. rendered-dir "frames"))
390 targets (map #(.getCanonicalPath
391 (File. final-frames (format "%07d.bmp" %)))
392 (range (count screenshots)))]
393 (dorun
394 (map
395 (comp
396 (partial apply clojure.java.shell/sh)
397 flatten
398 (partial apply adv-composite-frames-command)
399 (fn [a b d] (println d) [a b d]))
400 move-images screenshots targets))))
401
344 (defn advanced-step-1! [] 402 (defn advanced-step-1! []
345 (render-files! 403 (render-files!
346 advanced-render-dir 404 advanced-render-dir
405 adv-write-move-image!
406 false
347 (root) (advanced-steps))) 407 (root) (advanced-steps)))
348 408
349 (defn advanced-step-2! [] 409 (defn advanced-step-2! []
350 (generate-composite-frames! 410 (adv-generate-composite-frames!
351 advanced-render-dir)) 411 advanced-render-dir))
352 412
353 (defn advanced-step-3! [] (final-cut! advanced-render-dir)) 413 (defn advanced-step-3! [] (final-cut! advanced-render-dir))
354 414
355 415