Skip to content

Instantly share code, notes, and snippets.

@ato
Created November 24, 2009 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ato/241856 to your computer and use it in GitHub Desktop.
Save ato/241856 to your computer and use it in GitHub Desktop.
(defn inside? [[z-re z-im]]
(> (+ (* z-re z-re) (* z-im z-im)) 4))
(defn step [c-re c-im [z-re z-im]]
[(+ (* 2 z-re z-im) c-im)
(+ (- (* z-re z-re) (* z-im z-im)) c-re)])
(doseq [y (range image-height)
:let [c-im (- max-im (y * im-factor))]
x (range image-width)]
(let [c-re (+ min-re (x * re-factor))]
(when (some inside?
(take max-iterations
(iterate #(step c-re c-im %) [c-re c-im])))
(put-pixel x y))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment