Skip to content

Commit

Permalink
Added applet namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Aug 29, 2009
1 parent 831460f commit dffaec5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/rosado/processing/applet.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(ns rosado.processing.applet
(:use rosado.processing)
(:import (java.awt Frame)))

(defmacro defapplet
[name title setup draw width height]
`(do
(def ~name
(proxy [processing.core.PApplet] []
(setup []
(binding [*applet* ~'this]
(size ~width ~height)
(~setup)))
(draw []
(binding [*applet* ~'this]
(~draw)))))
(defn ~(symbol (str "run-" name)) []
(.init ~name)
(def ~(symbol (str name "-frame")) (doto (Frame. ~title)
(.setSize ~width ~height)
(.add ~name)
(.pack)
(.show))))

(defn ~(symbol (str "stop-" name)) []
(.destroy ~name)
(.hide ~(symbol (str name "-frame"))))))

0 comments on commit dffaec5

Please sign in to comment.