Skip to content

Instantly share code, notes, and snippets.

@quephird
Last active December 31, 2015 06:49
Show Gist options
  • Save quephird/7949918 to your computer and use it in GitHub Desktop.
Save quephird/7949918 to your computer and use it in GitHub Desktop.
(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