Skip to content

Instantly share code, notes, and snippets.

@quephird
Created December 4, 2013 14:13
Show Gist options
  • Save quephird/7788042 to your computer and use it in GitHub Desktop.
Save quephird/7788042 to your computer and use it in GitHub Desktop.
A ripoff of a really cool animation from here: http://fyprocessing.tumblr.com/post/68788311938/p5art-wobble-code-here
(ns wobble
(:use quil.core))
(def screen-w 800)
(def screen-h 800)
(def phase (atom 0))
(defn setup []
(background 0)
(no-stroke)
(frame-rate 30))
(defn draw []
(background 0)
(let [number-of-slices 30
radians-per-slice (radians (/ 360 number-of-slices))
colors [[238 214 154]
[251 107 98]
[228 52 72]
[140 42 56]
[50 37 53]]]
(translate (/ screen-w 2) (/ screen-h 2))
(doseq [i (range number-of-slices)]
(apply fill (colors (rem i (count colors))))
(begin-shape :quads)
(let [half-slice-length (+ 50 (* 50 (Math/sin (+ (* 3 i radians-per-slice) @phase))))
slice-center-radius 250
outer-radius (+ slice-center-radius half-slice-length)
inner-radius (- slice-center-radius half-slice-length)
outer-slice-width (* outer-radius radians-per-slice)
inner-slice-width (* inner-radius radians-per-slice)]
(vertex (* outer-slice-width -0.5) (- outer-radius))
(vertex (* inner-slice-width -0.5) (- inner-radius))
(vertex (* inner-slice-width 0.5) (- inner-radius))
(vertex (* outer-slice-width 0.5) (- outer-radius))
)
(end-shape)
(rotate radians-per-slice)
)
)
(swap! phase + (radians 20))
)
(sketch
:title "wobble"
:setup setup
:draw draw
:size [800 800]
:renderer :p2d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment