Skip to content

Instantly share code, notes, and snippets.

@quephird
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quephird/8d08c41c43d3252db4c1 to your computer and use it in GitHub Desktop.
Save quephird/8d08c41c43d3252db4c1 to your computer and use it in GitHub Desktop.
This is another adaptation from a wonderful thread on SO: http://codegolf.stackexchange.com/questions/35569/tweetable-mathematical-art
(ns fun-with-quil.breezy
(:use quil.core))
(def ^:constant screen-w 1920)
(def ^:constant screen-h 1080)
(defn r ^double [^long x ^long y]
(loop [k 0 i 0.0 j 0.0]
(let [si (sin i)
cj (cos j)]
(if (< k 15)
(recur (inc k) (+ (- (* si si) (* cj cj)) (/ (- x 0.0) 1024.0)) (+ (* 2 si cj) (/ (- y 1024.0) 512.0)))
(* 90.0 (abs j)))
)
)
)
(defn g ^double [^long x ^long y]
(loop [k 0 i 0.0 j 0.0]
(let [si (sin i)
cj (cos j)]
(if (< k 15)
(recur (inc k) (+ (- (* si si) (* cj cj)) (/ (- x 512.0) 1024.0)) (+ (* 2 si cj) (/ (- y 512.0) 512.0)))
(* 90.0 (abs i)))
)
)
)
(defn b ^double [^long x ^long y]
(loop [k 0 i 0.0 j 0.0]
(let [si (sin i)
cj (cos j)]
(if (< k 15)
(recur (inc k) (+ (- (* si si) (* cj cj)) (/ (- x 1024.0) 1024)) (+ (* 2 si cj) (/ (- y 0.0) 512)))
(* 50 (+ (sq i) (sq j))))
)
)
)
(defn setup []
(smooth)
(no-loop)
)
(defn draw []
(doseq [x (range screen-w)
y (range screen-h)]
(let [c [(r x y) (g x y) (b x y)]]
(apply stroke c)
(point x y)
)
)
)
(sketch
:title "breezy"
: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