Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Port to quil.

  • Loading branch information...
commit 4ac594997de008ea119661eedac332ad1c147b05 1 parent b9bb285
@technomancy authored
View
3  .gitignore
@@ -1 +1,2 @@
-target
+target/
+native/
View
11 project.clj
@@ -1,8 +1,3 @@
-{:name "sketchbook"
- :version "1.0.0-SNAPSHOT"
- :main sketchbook.menu
- :dependencies [["clojure" "1.0.0" "org.clojure"]
- ["clojure-contrib" "1.0-SNAPSHOT" "org.clojure"]
- ["processing.core" "1.0.6" "org.processing"]]
- :source-dependencies [["clj-processing" "master"
- :git "git://github.com/technomancy/clj-processing.git"]]}
+(defproject technomancy/sketchbook "1.0.0"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [quil "1.0.0"]])
View
0  src/DejaVuSansMono-Bold-36.vlw → resources/DejaVuSansMono-Bold-36.vlw
File renamed without changes
View
0  src/sketchbook/sample.log → resources/sample.log
File renamed without changes
View
11 src/sketchbook/chu.clj
@@ -1,6 +1,5 @@
(ns sketchbook.chu
- (:use [rosado.processing]
- [rosado.processing.applet]))
+ (:use [quil.core]))
(def step 10)
@@ -13,14 +12,10 @@
(smooth)
(background-float 0)
(stroke-int 255)
- (framerate 0)
(chu-curve 0)
(with-translation [(width) (height)]
(with-rotation [PI]
(chu-curve 0))))
-(defapplet chu :title "That Thing I Always Used to Draw in Math Class"
- :setup setup :width 512 :height 512)
-
-;; (run chu)
-;; (stop chu)
+(defsketch chu :title "That Thing I Always Used to Draw in Math Class"
+ :setup setup :size [512 512])
View
8 src/sketchbook/gox.clj
@@ -1,6 +1,5 @@
(ns sketchbook.gox
- (:use [rosado.processing]
- [rosado.processing.applet]))
+ (:use [quil.core]))
(defn rotator [x y x-spin y-spin]
(ellipse (+ x (* (sin (/ (frame-count) 10.0)) (* 100
@@ -19,9 +18,6 @@
(rotator 100 350 -1 1)
(rotator 350 350 -1 -1))
-(defapplet gox :title "Maybe something involving trig."
+(defsketch gox :title "Maybe something involving trig."
:setup (fn [] (smooth) (no-stroke))
:draw draw :size [640 480])
-
-;; (run gox)
-;; (stop gox)
View
21 src/sketchbook/log.clj
@@ -1,15 +1,11 @@
(ns sketchbook.log
- (:use [rosado.processing]
- [rosado.processing.applet]
- [clojure.contrib.str-utils :only [re-split]]
- [clojure.contrib.duck-streams :only [reader]])
+ (:use [quil.core])
+ (:require [clojure.string :as string]
+ [clojure.java.io :as io])
(:import [java.util Date]))
;; Point this at a web server log file!
-(def lines (atom (line-seq (reader (.getResourceAsStream
- (.getContextClassLoader
- (Thread/currentThread))
- "sketchbook/sample.log")))))
+(def lines (atom (line-seq (io/reader (io/resource "sketchbook/sample.log")))))
(def last-time (atom false))
@@ -33,7 +29,7 @@
(map #(Integer/parseInt %) (drop 3 parts)))))
(defn draw-line [[ip time code size]]
- (let [segments (map #(Integer/parseInt %) (re-split #"\." ip))
+ (let [segments (map #(Integer/parseInt %) (string/split ip #"\."))
radius (* (Math/log (Integer/parseInt size)) 10)]
(fill-int 255)
(ellipse (+ (nth segments 0)
@@ -52,15 +48,12 @@
time (.getTime (parse-time (second the-line)))]
(draw-line the-line)
(when @last-time
- (.delay *applet* (Math/log (- time @last-time))))
+ (delay-frame (Math/log (- time @last-time))))
(reset! last-time time))
(no-loop))
(fade-background)
(swap! lines rest))
-(defapplet log :title "Log visualizer"
+(defsketch loggo :title "Log visualizer"
:setup (fn [] (no-stroke) (background-int 0)) :draw draw
:width 510 :height 510)
-
-;; (run log)
-;; (stop log)
View
16 src/sketchbook/myu.clj
@@ -1,6 +1,5 @@
(ns sketchbook.myu
- (:use [rosado.processing]
- [rosado.processing.applet]))
+ (:use [quil.core]))
;; TODO: calculate position as a function of frame-count instead of by mutation
(def vortex (atom [0 0]))
@@ -11,9 +10,9 @@
(sin (/ (frame-count) 5.0)))
(defn bounce! []
- (when (or (> (first @vortex) (.getWidth *applet*)) (neg? (first @vortex)))
+ (when (or (> (first @vortex) (width)) (neg? (first @vortex)))
(swap! vortex-velocity (fn [[x y]] [(- x) y])))
- (when (or (> (last @vortex) (.getHeight *applet*)) (neg? (last @vortex)))
+ (when (or (> (last @vortex) (height)) (neg? (last @vortex)))
(swap! vortex-velocity (fn [[x y]] [x (- y)]))))
(defn move! []
@@ -31,14 +30,11 @@
(background-float 0)
(smooth)
(no-stroke)
- (framerate 40))
+ (frame-rate 40))
(defn draw []
(move!)
(draw-vortex (* 150 (/ (+ (sine-frame) 1) 2))))
-(defapplet myu :title "Something vaguely Birdlike"
- :setup setup :draw draw :width 800 :height 600)
-
-;; (run myu)
-;; (stop myu)
+(defsketch myu :title "Something vaguely Birdlike"
+ :setup setup :draw draw :size [800 600])
View
10 src/sketchbook/pch.clj
@@ -1,9 +1,8 @@
(ns sketchbook.pch
- (:use [rosado.processing]
- [rosado.processing.applet]))
+ (:use [quil.core]))
(defn setup []
- (color-mode HSB)
+ ;; (color-mode HSB)
(fill-int 255)
(no-stroke)
(rect 0 0 (width) (height))
@@ -17,8 +16,5 @@
b (* 2 a)]
(triangle a a b a a b)))))
-(defapplet pch :title "Peachy Keen"
+(defsketch pch :title "Peachy Keen"
:setup setup :draw draw :size [400 400])
-
-;; (run pch)
-;; (stop pch)
View
15 src/sketchbook/pop.clj
@@ -1,7 +1,6 @@
(ns sketchbook.pop
(:refer-clojure :exclude [pop])
- (:use [rosado.processing]
- [rosado.processing.applet]))
+ (:use [quil.core]))
;; TODO: define these modulo frame-count instead of by mutation
(def x (atom 0))
@@ -9,10 +8,10 @@
(defn setup []
(no-stroke)
- (framerate 12))
+ (frame-rate 12))
(defn draw []
- (fill-float (* 255 (noise @x @y (.frameCount *applet*))))
+ (fill-float (* 255 (noise @x @y (frame-count))))
(rect (+ (* @x 100) 10)
(+ (* @y 100) 10)
90 90)
@@ -22,9 +21,5 @@
(reset! x 0)
(swap! y #(mod (inc %) 5))))
-(defapplet pop :title "Synthpop-inspired Jams"
- :setup setup :draw draw :width 510 :height 510)
-
-;; To make things go:
-;; (run pop)
-;; (stop pop)
+(defsketch pop :title "Synthpop-inspired Jams"
+ :setup setup :draw draw :size [510 510])
Please sign in to comment.
Something went wrong with that request. Please try again.