Created
April 10, 2014 17:41
-
-
Save tangrammer/10405691 to your computer and use it in GitHub Desktop.
changes on quil2.0 to add movie support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gen-interface | |
:name quil.MovieI | |
:methods [ | |
[movieEvent | |
[processing.video.Movie] Object] | |
]) | |
(gen-class | |
:name "quil.Applet" | |
:implements [clojure.lang.IMeta quil.MovieI] | |
:extends processing.core.PApplet | |
;:methods [[movieEvent [processing.video.Movie] Object]] | |
:state state | |
:init quil-applet-init | |
:post-init quil-applet-post-init | |
:constructors {[java.util.Map] []} | |
:exposes-methods {keyTyped keyTypedParent | |
loop loopParent | |
mouseDragged mouseDraggedParent | |
keyPressed keyPressedParent | |
mouseExited mouseExitedParent | |
mouseClicked mouseClickedParent | |
mouseEntered mouseEnteredParent | |
mouseMoved mouseMovedParent | |
keyReleased keyReleasedParent | |
mousePressed mousePressedParent | |
focusGained focusGainedParent | |
frameRate frameRateParent | |
mouseReleased mouseReleasedParent | |
focusLost focusLostParent | |
noLoop noLoopParent}) | |
;;; ..... | |
(defn applet | |
[& opts] | |
(let [options (merge {:size [500 300] | |
:target :frame | |
:safe-draw-fn true} | |
(apply hash-map opts)) | |
size (process-size (:size options)) | |
target (validate-target! (:target options)) | |
title (or (:title options) (str "Quil " (swap! untitled-applet-id* inc))) | |
renderer (or (:renderer options) :java2d) | |
draw-fn (or (:draw options) no-fn) | |
setup-fn (or (:setup options) no-fn) | |
movie-event-fn (or (:movie-event options) (fn [ movie] (println "default movie-event") #_(.read movie))) | |
safe-draw-fn (fn [] | |
(try | |
(draw-fn) | |
(catch Exception e | |
(println "Exception in Quil draw-fn for sketch" title ": " e "\nstacktrace: " (with-out-str (print-cause-trace e))) | |
(Thread/sleep 1000)))) | |
draw-fn (if (:safe-draw-fn options) safe-draw-fn draw-fn) | |
on-close-fn (or (:on-close options) no-fn) | |
state (atom nil) | |
target-obj (atom nil) | |
looping? (atom true) | |
listeners (into {} (for [name listeners] | |
[name (or (options name) no-fn)])) | |
applet-state (merge options | |
{:state state | |
:target-obj target-obj | |
:target target | |
:looping? looping? | |
:on-close on-close-fn | |
:setup-fn setup-fn | |
:draw-fn draw-fn | |
:movie-event movie-event-fn | |
:renderer renderer | |
:size size | |
:target-frame-rate (atom 60)} | |
listeners) | |
prx-obj (quil.Applet. applet-state) | |
] | |
(doto prx-obj | |
(applet-run title renderer target) | |
(attach-applet-listeners)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns dat00.juan | |
(:import (processing.video Movie))) | |
(declare mov) | |
(defn setup[] | |
(println "setup completed!") | |
) | |
(defn draw [] | |
(image mov 0 0 )) | |
(defsketch juan | |
:setup setup | |
:draw draw | |
:size [500 500] | |
:movie-event (fn [movie] (println "reading!!") (.read movie))) | |
(def mov (Movie. juan "data/transit.mov")) | |
(.play mov) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject quil "2.0.1-SNAPSHOT" | |
:description "(mix Processing Clojure)" | |
:url "http://github.com/quil/quil" | |
:mailing-list {:name "Quil Mailing List" | |
:archive "https://groups.google.com/forum/?fromgroups#!forum/clj-processing" | |
:post "clj-processing@googlegroups.com"} | |
:license {:name "Common Public License - v 1.0" | |
:url "http://www.opensource.org/licenses/cpl1.0"} | |
:repositories [["jogamp" "http://www.jogamp.org/deployment/maven/"]] | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[quil/processing-core "2.1.1"] | |
[quil/processing-pdf "2.1.1"] | |
[quil/processing-dxf "2.1.1"] | |
[org.jogamp.jogl/jogl-all-main "2.1.4-rc-20140113"] | |
[org.jogamp.gluegen/gluegen-rt-main "2.1.4-rc-20140113"]] | |
:resource-paths ["lib/gstreamer-java.jar" "lib/video.jar" "lib/jna.jar" "lib/macosx64"] | |
:aot [quil.helpers.applet-listener quil.applet]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment