Created
December 13, 2013 04:09
-
-
Save quephird/7939657 to your computer and use it in GitHub Desktop.
Inspired by this: http://koku-chou.tumblr.com/post/69509732291/circles
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 pixercles | |
(:use quil.core)) | |
(def screen-w 2000) | |
(def screen-h 1000) | |
(defn- rand-color [] | |
(vec (repeatedly 3 (fn [] (rand-int 255))))) | |
(defn- vary-color [c] | |
(let [delta-c (vec (repeatedly 3 (fn [] (- (rand-int 40) 20))))] | |
(map + c delta-c))) | |
(defn- generate-palette [n] | |
(vec (repeatedly n (fn [] (rand-color))))) | |
(defn- cell [radius palette opacity] | |
(let [seed-color (palette (rand-int (count palette))) | |
desired-color (vary-color seed-color)] | |
(apply fill (conj desired-color opacity)) | |
(ellipse 0 0 radius radius))) | |
(defn setup [] | |
(smooth) | |
(no-loop)) | |
(defn draw [] | |
(let [bg-color [0 0 0] | |
radius 75 | |
circle-distance (* radius 0.7) | |
columns (inc (/ screen-w circle-distance)) | |
rows (inc (/ screen-h circle-distance)) | |
circle-color [255 255 255] | |
circle-thickness 2 | |
palette (generate-palette 5) | |
opacity 150] | |
(apply background bg-color) | |
(ellipse-mode :center) | |
(stroke-weight circle-thickness) | |
(apply stroke circle-color) | |
(doseq [y (range rows)] | |
(push-matrix) | |
(doseq [x (range columns)] | |
(cell radius palette opacity) | |
(translate circle-distance 0) | |
) | |
(pop-matrix) | |
(translate 0 circle-distance) | |
) | |
) | |
(display-filter :blur 1) | |
(save "pixercles.png") | |
) | |
(defsketch main | |
:title "pixercles" | |
: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