Skip to content

Instantly share code, notes, and snippets.

@JonathanSmith
Created October 11, 2009 01:38
Show Gist options
  • Save JonathanSmith/207314 to your computer and use it in GitHub Desktop.
Save JonathanSmith/207314 to your computer and use it in GitHub Desktop.
(defmap hsv-color-fractal
(let [val %
z (.xy val)
n (.z val)
normalized-count (/ (- n (log2 (log2 (sqrt (+ (* (.x z) (.x z)) (* (.y z) (.y z)))))))
(float max-iterations))
h (* 360.0 normalized-count)
s 0.8
v 1.0
h_v (floor (/ h 60.0))
hi (float (mod h_v 6.0))
f (- (/ h 60.0) h_v)
p (* v (- v s))
q (* v (- v (* f s)))
t (* v (- v (* (- v f) s)))]
(? (< 4.0 (dot z z))
(? (= hi 0.0)
(color3 v t p)
(? (= hi 1.0)
(color3 q v p)
(? (= hi 2.0)
(color3 p v t)
(? (= hi 3.0)
(color3 p q v)
(? (= hi 4.0)
(color3 t p v)
(color3 v p q))))))
(color3 0.0 0.0 0.0))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment