Skip to content

Instantly share code, notes, and snippets.

@quephird
Created May 9, 2012 18:14
Show Gist options
  • Save quephird/2647549 to your computer and use it in GitHub Desktop.
Save quephird/2647549 to your computer and use it in GitHub Desktop.
purple circles with quil
(ns purple-circles
(:use quil.core))
(def *screen-x* 1920)
(def *screen-y* 1080)
(def *circle-d* 64)
(def *rows* (+ 3 (quot *screen-x* *circle-d*)))
(def *cols* (inc (quot *screen-y* *circle-d*)))
(defn- random-rgb []
[(random 127) 0 (+ 127 (random 127))])
(defn- random-row-col []
(map #(Math/floor %) [(random *rows*) (random *cols*)]))
(defn setup []
(smooth)
(background 0)
(no-loop))
(defn draw-all-at-once []
(doseq [r (range *rows*) c (range *cols*)]
(apply stroke (random-rgb))
(stroke-weight 10)
(apply fill (random-rgb))
(ellipse (cond (zero? (mod c 2)) (* r *circle-d*) :else (* (+ r 0.5) *circle-d*))
(* c *circle-d*)
*circle-d*
*circle-d*))
(save "purple-circles.png"))
(defsketch main
:title "Circles"
:setup setup
:draw draw-all-at-once
:size [*screen-x* *screen-y* ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment