Created
May 14, 2012 20:44
-
-
Save samaaron/2696735 to your computer and use it in GitHub Desktop.
Quil Animated Spiragraph Experiments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns spiragraph | |
(:use [quil.core] | |
[quil.helpers.drawing :only [line-join-points]] | |
[quil.helpers.seqs :only [range-incl]])) | |
(defn setup [] | |
(background 255) | |
(stroke-weight 5) | |
(smooth)) | |
(defn circle [radius cent-x cent-y n-lines] | |
(let [rads (sort (take n-lines (shuffle (range 0 360)))) | |
xs (map #(+ cent-x (* radius (cos %))) rads) | |
ys (map #(+ cent-y (* radius (sin %))) rads)] | |
(stroke 0 30) | |
(no-fill) | |
(ellipse cent-x cent-y (* radius 2) (* radius 2)) | |
(stroke (rand 25) (rand 25) (rand 25) 40) | |
(dorun (map #(apply line %) (line-join-points xs ys))))) | |
(defn draw [] | |
(fill 255 40) | |
(rect 0 0 (width) (height)) | |
(frame-rate 50) | |
(stroke-weight 1.5) | |
(circle 10 50 60 10) | |
(circle 20 70 100 20) | |
(circle 30 100 120 30) | |
(circle 50 150 160 30) | |
(circle 300 50 60 10) | |
(circle 80 300 100 100) | |
(circle 150 100 100 100) | |
(circle 500 300 100 10) | |
(display-filter :posterize 10)) | |
(defsketch spiragraph | |
:title "Spiragraph" | |
:setup setup | |
:draw draw | |
:target :perm-frame | |
:size [500 300]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment