Skip to content
Browse files

Switch to text-based menu.

  • Loading branch information...
1 parent 87edd81 commit 42d7508a113517bd1b40710c8d7989538a1886d9 @technomancy committed
Showing with 11 additions and 44 deletions.
  1. +2 −1 project.clj
  2. +9 −43 src/sketchbook/menu.clj
View
3 project.clj
@@ -1,3 +1,4 @@
(defproject technomancy/sketchbook "1.0.0"
:dependencies [[org.clojure/clojure "1.3.0"]
- [quil "1.0.0"]])
+ [quil "1.0.0"]]
+ :main sketchbook.menu)
View
52 src/sketchbook/menu.clj
@@ -1,48 +1,14 @@
(ns sketchbook.menu
- (:use [rosado.processing.applet]
- [rosado.processing])
(:gen-class))
-(def sketches '[chu myu pop log])
+(def sketches '#{chap chu gox myu pch pop log})
-(doseq [s sketches]
- (require (symbol (str "sketchbook." (name s)))))
+(defn help []
+ (println "Please provide a sketch to display.")
+ (apply println "Available sketches:" (seq sketches))
+ (System/exit 1))
-(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)
+(defn -main [& [sketch]]
+ (if (and sketch (sketches (symbol sketch)))
+ (require (symbol (str "sketchbook." sketch)))
+ (help)))

0 comments on commit 42d7508

Please sign in to comment.
Something went wrong with that request. Please try again.