Skip to content

Instantly share code, notes, and snippets.

@robertseaton
Created May 4, 2012 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertseaton/2596287 to your computer and use it in GitHub Desktop.
Save robertseaton/2596287 to your computer and use it in GitHub Desktop.
squared 2d noise grid w/ len-based fill
(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