Created
May 15, 2012 00:27
-
-
Save quephird/2698274 to your computer and use it in GitHub Desktop.
color-walk
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 color-walk | |
(:use quil.core)) | |
(def screen-w 1920) | |
(def screen-h 1080) | |
(def current-color (atom [])) | |
(defn- init-current-color [] | |
(doseq [i (range 3)] | |
(swap! current-color assoc i (random 255)))) | |
(defn- change-current-color [] | |
(doseq [i (range 3)] | |
(let [change-direction (random 3) | |
current-color-value (@current-color i)] | |
(cond | |
(< change-direction 1) (swap! current-color assoc i (- current-color-value 5)) | |
(> change-direction 2) (swap! current-color assoc i (+ current-color-value 5)) | |
:else nil)))) | |
(defn setup [] | |
(init-current-color) | |
(smooth) | |
(background 0) | |
(no-loop)) | |
(defn draw [] | |
(doseq [x (range screen-w)] | |
(apply stroke @current-color) | |
(line x 0 x screen-h) | |
(change-current-color)) | |
(save "color-walk.png")) | |
(defsketch main | |
:title "Color walk" | |
:setup setup | |
:draw draw | |
:size [screen-w screen-h]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment