Last active
December 31, 2015 06:49
-
-
Save quephird/7949918 to your computer and use it in GitHub Desktop.
Inspired by http://cutsquash.tumblr.com/post/69393595011
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 lines-of-circles | |
(:use quil.core)) | |
(def screen-w 800) | |
(def screen-h 1000) | |
(defn- line-of-circles [length stroke-c fill-c] | |
(apply stroke stroke-c) | |
(apply fill fill-c) | |
(let [init-r (+ 75 (rand-int 50)) | |
ys (range 0 length 2) | |
rs (reductions + (cons init-r (repeatedly length #(* 5 (- (rand-int 3) 1))))) | |
ys-and-rs (map vector ys rs)] | |
(doseq [[y r] ys-and-rs] | |
(ellipse 0 y r r)) | |
) | |
) | |
(defn setup [] | |
(smooth) | |
(no-stroke) | |
(background 0) | |
(no-loop) | |
) | |
(defn draw [] | |
(ellipse-mode :corner) | |
(push-matrix) | |
(translate (/ screen-w 2) -50) | |
(line-of-circles 1100 [127 0 127] [31 31 31]) | |
(pop-matrix) | |
(push-matrix) | |
(translate (/ screen-w 2) (+ screen-h 50)) | |
(rotate (radians 180)) | |
(line-of-circles 1100 [0 127 127] [31 31 31]) | |
(pop-matrix) | |
(save "lines-of-circles.png") | |
) | |
(sketch | |
:title "lines-of-circles" | |
:setup setup | |
:draw draw | |
:size [screen-w screen-h] | |
:renderer :p2d | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment