Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added "chu" sketch.

  • Loading branch information...
commit b6e9c2f857f971d05e02b09eb99746520a0a5743 1 parent 6313522
@technomancy authored
View
8 README.md
@@ -15,4 +15,12 @@ Then run with:
To install corkscrew, see http://github.com/technomancy/corkscrew
+## Sketches
+
+Pop, or "Synthpop-inspired Jams": http://github.com/technomancy/sketchbook/blob/master/src/sketchbook/pop.clj
+
+Myu, or "Something vaguely Birdlike": http://github.com/technomancy/sketchbook/blob/master/src/sketchbook/myu.clj
+
+Chu or ""That Thing I Always Used to Draw in Math Class": http://github.com/technomancy/sketchbook/blob/master/src/sketchbook/chu.clj
+
Copyright (c) 2009 Phil Hagelberg; see file COPYING for details.
View
32 src/sketchbook/chu.clj
@@ -0,0 +1,32 @@
+(ns sketchbook.chu
+ (:use [rosado.processing]
+ [rosado.processing.applet]))
+
+(def step 10)
+
+(defn height []
+ (.getHeight *applet*))
+
+(defn width []
+ (.getWidth *applet*))
+
+(defn chu-curve [n]
+ (line n 0 0 (- (height) n))
+ (if (< n (height))
+ (recur (+ n step))))
+
+(defn setup []
+ (smooth)
+ (background-float 0)
+ (stroke-int 255)
+ (framerate 0)
+ (chu-curve 0)
+ (with-translation [(width) (height)]
+ (with-rotation [PI]
+ (chu-curve 0))))
+
+(defapplet chu "That Thing I Always Used to Draw in Math Class"
+ setup #() 512 512)
+
+;; (run-chu)
+;; (stop-chu)
View
4 src/sketchbook/myu.clj
@@ -4,7 +4,7 @@
(defn frame-count [] (.frameCount *applet*))
-(def last-vortex (atom [0 0]))
+;; TODO: calculate position as a function of frame-count instead of by mutation
(def vortex (atom [0 0]))
(def vortex-size 20)
(def vortex-velocity (atom [10 10]))
@@ -39,7 +39,7 @@
(move!)
(draw-vortex (* 150 (/ (+ (sine-frame) 1) 2))))
-(defapplet myu "Something vaguely birdlike"
+(defapplet myu "Something vaguely Birdlike"
setup draw 800 600)
;; (run-myu)
View
22 src/sketchbook/pop.clj
@@ -3,20 +3,24 @@
(:use [rosado.processing]
[rosado.processing.applet]))
-(def generation (atom 0.0))
+;; TODO: define these modulo frame-count instead of by mutation
+(def x (atom 0))
+(def y (atom 0))
(defn setup []
(no-stroke)
- (framerate 5))
+ (framerate 12))
(defn draw []
- (swap! generation inc)
- (dotimes [x 5]
- (dotimes [y 5]
- (fill-float (* 255 (noise x y @generation)))
- (rect (+ (* x 100) 10)
- (+ (* y 100) 10)
- 90 90))))
+ (fill-float (* 255 (noise @x @y (.frameCount *applet*))))
+ (rect (+ (* @x 100) 10)
+ (+ (* @y 100) 10)
+ 90 90)
+
+ (swap! x inc)
+ (when (>= @x 5)
+ (reset! x 0)
+ (swap! y #(mod (inc %) 5))))
(defapplet pop "Synthpop-inspired Jams"
setup draw 510 510)
Please sign in to comment.
Something went wrong with that request. Please try again.