Created
November 14, 2013 02:09
-
-
Save quephird/7460126 to your computer and use it in GitHub Desktop.
Another knockoff: https://twitter.com/LorenBednar/status/400728973644017664/
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 lots-o-dots | |
(:use quil.core)) | |
(def screen-w 1600) | |
(def screen-h 800) | |
(defn- setup [] | |
(background 0) | |
(smooth) | |
(no-stroke) | |
(no-loop) | |
) | |
(defn- rand-color [] | |
(into [] (repeatedly 3 (fn [] (rand-int 255))))) | |
(defn- cell [cell-w] | |
(ellipse-mode :center) | |
(let [dot-d (* cell-w 0.5) | |
outer-arc-d (* cell-w 0.7) | |
outer-arc-stroke-w (* cell-w 0.08) | |
bottom-left-arc-d (* dot-d 0.8) | |
bottom-left-arc-stroke-w (* cell-w 0.1) | |
top-right-arc-d (* dot-d 0.9) | |
top-right-arc-stroke-w (* cell-w 0.025) | |
] | |
(apply fill (rand-color)) | |
(ellipse 0 0 dot-d dot-d) | |
(no-fill) | |
(apply stroke (rand-color)) | |
(stroke-weight outer-arc-stroke-w) | |
(arc 0 0 outer-arc-d outer-arc-d (radians 180) (radians 450)) | |
(apply stroke (rand-color)) | |
(stroke-weight bottom-left-arc-stroke-w) | |
(arc 0 0 bottom-left-arc-d bottom-left-arc-d (radians 90) (radians 180)) | |
(apply stroke (rand-color)) | |
(stroke-weight top-right-arc-stroke-w) | |
(arc 0 0 top-right-arc-d top-right-arc-d (radians 270) (radians 360)) | |
(no-stroke) | |
) | |
) | |
(defn draw [] | |
(let [cell-w 50 | |
rows (/ screen-h cell-w) | |
columns (/ screen-w cell-w)] | |
(translate (/ cell-w 2) (/ cell-w 2)) | |
(doseq [r (range rows)] | |
(push-matrix) | |
(doseq [c (range columns)] | |
(cell cell-w) | |
(translate cell-w 0) | |
) | |
(pop-matrix) | |
(translate 0 cell-w) | |
) | |
) | |
(display-filter :blur 1) | |
(save "lots-o-dots.png") | |
) | |
(sketch | |
:title "lots-o-dots" | |
:setup setup | |
:draw draw | |
:size [screen-w screen-h] | |
:renderer :java2d | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment