Skip to content

Instantly share code, notes, and snippets.

@quephird
Created May 15, 2012 00:27
Show Gist options
  • Save quephird/2698274 to your computer and use it in GitHub Desktop.
Save quephird/2698274 to your computer and use it in GitHub Desktop.
color-walk
(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