Created
May 10, 2012 13:00
-
-
Save quephird/2652871 to your computer and use it in GitHub Desktop.
concentric squares
This file contains 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 concentric-squares | |
(:use quil.core)) | |
(def *screen-x* 1920) | |
(def *screen-y* 1080) | |
(def *square-w* 64) | |
(def *rows* (inc (quot *screen-x* *square-w*))) | |
(def *cols* (inc (quot *screen-y* *square-w*))) | |
(defn- random-rgb [] | |
[(random 255) (random 255) (random 255)]) | |
(defn setup [] | |
(smooth) | |
(background 0) | |
(no-loop)) | |
(defn draw [] | |
(no-stroke) | |
(doseq [r (range *rows*) c (range *cols*)] | |
(let [left-corner-x (* r *square-w*) | |
left-corner-y (* c *square-w*) | |
right-corner-x (+ left-corner-x *square-w*) | |
right-corner-y (+ left-corner-y *square-w*)] | |
(doseq [square-num (range 3)] | |
(apply fill (random-rgb)) | |
(rect (+ left-corner-x (* 12 square-num)) | |
(+ left-corner-y (* 12 square-num)) | |
(- *square-w* (* 24 square-num)) | |
(- *square-w* (* 24 square-num)))))) | |
(save "concentric-squares.png")) | |
(defsketch main | |
:title "Concentric squares" | |
:setup setup | |
:draw draw | |
:size [*screen-x* *screen-y*]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment