Skip to content

Instantly share code, notes, and snippets.

@puredanger
Forked from quephird/breezy.clj
Last active August 29, 2015 14:05
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 puredanger/8e6811b234792dd0bbba to your computer and use it in GitHub Desktop.
Save puredanger/8e6811b234792dd0bbba to your computer and use it in GitHub Desktop.
Added type hints I suspect would make math faster here. Just eyeballing, so not sure if it's all right. Normally I would check the bytecode to look for boxing as well.
(ns fun-with-quil.breezy
(:use quil.core))
(set! *unchecked-math* true)
(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)]
(if (< k 15)
(recur (inc k) (+ (- (sq (sin i)) (sq (cos j))) (/ (- x 0.0) 1024)) (+ (* 2 (sin i) (cos j)) (/ (- y 1024.0) 512)))
(* 90 (abs j)))
)
)
(defn g ^double [^long x ^long y]
(loop [k 0 i 0.0 j 0.0]
(if (< k 15)
(recur (inc k) (+ (- (sq (sin i)) (sq (cos j))) (/ (- x 512.) 1024)) (+ (* 2 (sin i) (cos j)) (/ (- y 512.0) 512)))
(* 90 (abs i)))
)
)
(defn b ^double [^long x ^long y]
(loop [k 0 i 0.0 j 0.0]
(if (< k 15)
(recur (inc k) (+ (- (sq (sin i)) (sq (cos j))) (/ (- x 1024.) 1024)) (+ (* 2 (sin i) (cos j)) (/ (- y 0.0) 512)))
(* 50 (+ (sq i) (sq j))))
)
)
(defn setup []
(smooth)
(no-loop)
; (color-mode :hsb)
)
(defn draw []
(doseq [x (range screen-w)
y (range screen-h)]
(stroke (r x y) (g x y) (b x y))
(point x y))
(save "breezy.png"))
(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