Mercurial > vba-clojure
view clojure/com/aurellem/run/final_cut.clj @ 531:c6ad363e36f7
trying to find out map problem.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 24 Jun 2012 17:18:22 -0500 |
parents | 8d3177d19d5f |
children | a3bdff5554ad |
line wrap: on
line source
1 (ns com.aurellem.run.final-cut2 (:use (com.aurellem.gb saves gb-driver util constants3 items vbm characters money4 rlm-assembly))5 (:use (com.aurellem.run util sound music title save-corruption6 bootstrap-0 bootstrap-17 ram-display8 ))9 (:require clojure.string)10 (:import [com.aurellem.gb.gb_driver SaveState])11 (:import java.awt.image.BufferedImage)12 (:import java.io.File)13 (:import com.aurellem.gb.WaveWriter))16 (def render-dir (File. user-home "proj/vba-clojure/render"))18 (defn render-files!19 ([^File target-dir initial-state moves]20 (let [ram-map-dir (File. target-dir "ram-map")21 frames-dir (File. target-dir "frames")22 audio-file (File. target-dir "audio.wav")23 _ (.mkdirs ram-map-dir)24 _ (.mkdirs frames-dir)25 wave-writer (WaveWriter. audio-file)26 moves (vec moves)]27 (set-state! initial-state)28 (dorun29 (map30 (fn [index]31 (run-moves @current-state (vector (moves index)))33 ;; record audio34 (.process wave-writer (sound-bytes)35 gb-sound-format)37 ;; write screenshot38 (write-png!39 @current-state40 (File. frames-dir (format "%07d.png" index)))42 ;; write ram-image43 (write-ram-image!44 @current-state45 (File. ram-map-dir (format "%07d.png" index))))46 (range (count moves))))47 (.cleanup wave-writer)))48 ([initial-state moves]49 (render-files! render-dir initial-state moves))50 ([moves]51 (render-files! (root) moves)))53 (defn file-names [#^File dir]54 (mapv #(.getCanonicalPath %) (next (sort (file-seq dir)))))56 (defn composite-frames-command57 [screenshot ram-map target]58 ["convert"59 "-size" "318x276" "xc:white"60 screenshot "-geometry" "+10+10" "-composite"61 ram-map "-geometry" "+180+10" "-composite"62 target])64 (defn generate-composite-frames!65 ([^File rendered-dir]66 (let [final-frames (File. rendered-dir "final")67 _ (.mkdir final-frames)68 screenshots (file-names (File. rendered-dir "frames"))69 ram-maps (file-names (File. rendered-dir "ram-map"))70 targets (map #(File. final-frames (format "%07d.png"))71 (range (count screenshots)))]72 (dorun73 (map74 ;; (comp ;;clojure.java.shell/sh75 ;; println76 ;; flatten77 composite-frames-command78 screenshots ram-maps targets))80 ))81 ([] (generate-composite-frames! render-dir)))