Created
May 4, 2012 17:10
-
-
Save robertseaton/2596287 to your computer and use it in GitHub Desktop.
squared 2d noise grid w/ len-based fill
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 art.core | |
(:use quil.core | |
[quil.helpers.seqs :only [range-incl]] | |
[quil.helpers.calc :only [mul-add]])) | |
(defn to-color-range | |
[n] | |
(mod (* 255 n) 255)) | |
(defn draw-point | |
[x y noise-factor] | |
(let [len (* 10 noise-factor)] | |
(fill (to-color-range len)) | |
(rect x y len len))) | |
(defn draw-squares | |
[x-start y-start] | |
(dorun | |
(for [y (range-incl 0 (height) 5) | |
x (range-incl 0 (width) 5)] | |
(let [x-noise (mul-add x 0.01 x-start) | |
y-noise (mul-add y 0.01 y-start) | |
alph (* 255 (noise x-noise y-noise))] | |
(draw-point x y (noise x-noise y-noise)))))) | |
(defn setup [] | |
(smooth) | |
(background 255) | |
(draw-squares (random 10) (random 10))) | |
(defsketch squared-2d-noise-grid | |
:title "Squared 2D Noise Grid" | |
:setup setup | |
:size [750 750]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment