Browse files

Added menu launcher.

  • Loading branch information...
1 parent ba19e40 commit 052fc502e19b308c2bf4a0e9789bcd73a7a7341d @technomancy committed Sep 20, 2009
Showing with 48 additions and 0 deletions.
  1. BIN src/DejaVuSansMono-Bold-36.vlw
  2. +48 −0 src/sketchbook/menu.clj
View
BIN src/DejaVuSansMono-Bold-36.vlw
Binary file not shown.
View
48 src/sketchbook/menu.clj
@@ -0,0 +1,48 @@
+(ns sketchbook.menu
+ (:use [rosado.processing.applet]
+ [rosado.processing])
+ (:gen-class))
+
+(def sketches '[chu myu pop log])
+
+(doseq [s sketches]
+ (require (symbol (str "sketchbook." (name s)))))
+
+(defn in-bounds? [x y]
+ (and (> x 45)
+ (< x 145)
+ (> y 115)
+ (< y 385)))
+
+(defn which-sketch [x y]
+ (if (in-bounds? x y)
+ (nth sketches (/ (- y 110) 75))))
+
+(defn run-sketch [sketch]
+ (run (var-get (ns-resolve (symbol (str "sketchbook." (name sketch)))
+ sketch))))
+
+(defn setup []
+ (background-int 255)
+ (fill-int 0)
+ (text-font (load-font "DejaVuSansMono-Bold-36.vlw"))
+ (string->text "technomancy" 10 40)
+ (string->text "sketchbook" 15 80)
+
+ (dotimes [n (count sketches)]
+ (string->text (name (sketches n)) 65 (+ 150 (* 75 n)))))
+
+(defn mouseClicked [event]
+ (let [x (.getX event)
+ y(.getY event)]
+ (if (in-bounds? x y)
+ (run-sketch (which-sketch x y)))))
+
+(defapplet menu
+ :width 300 :height 800
+ :setup setup :mouseClicked mouseClicked)
+
+(defn -main []
+ (run menu))
+
+;; (stop menu)

0 comments on commit 052fc50

Please sign in to comment.