Created
January 31, 2014 12:57
-
-
Save wagjo/8731671 to your computer and use it in GitHub Desktop.
Playing with quil
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 foo.bar | |
(:use [quil.core]) | |
(:require [clojure.string :as s])) | |
(defn setup [] | |
(frame-rate 1) | |
(background 255)) | |
(def *scale* 2) | |
(defn draw-color [c o] | |
(let [x (bit-shift-right c 8) | |
y (bit-and c 16rff) | |
xt (* *scale* x) | |
yt (* *scale* y)] | |
(point (+ (* *scale* o) xt) yt))) | |
(defn r1 [] | |
(rand-int 16rFFFF)) | |
(def c [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \B \C \D \E \F]) | |
(defn r2 [] | |
(Long/parseLong (s/join (repeatedly 4 #(rand-nth c))) 16)) | |
(defn r3 [] | |
(Long/parseLong (s/join (take 4 (shuffle c))) 16)) | |
(defn draw [] | |
(background 255) | |
(stroke 0) | |
(stroke-weight 2) | |
(fill 0) | |
(doseq [c (take (* 256 256) (repeatedly r2))] | |
(draw-color c 0)) | |
(doseq [c (take (* 256 256) (repeatedly r3))] | |
(draw-color c 256))) | |
(defsketch foobar | |
:title "teh random colorz" | |
:setup setup | |
:draw draw | |
:size [1024 512]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment