2d wave edition

This commit is contained in:
Anish Lakhwara 2023-01-03 15:40:08 +10:00
parent 6d40c5695a
commit 26dade3b0f

View file

@ -22,32 +22,22 @@
{:color (mod (+ (:color state) 0.7) 255) {:color (mod (+ (:color state) 0.7) 255)
:angle (+ (:angle state) 0.1)}) :angle (+ (:angle state) 0.1)})
(def w 50)
(def offset (atom 0))
(defn draw-state [state] (defn draw-state [state]
; Set circle color.
(q/background 0) (q/background 0)
(q/fill (:color state) 255 255) (q/fill (:color state) 255 255)
(q/stroke (- (:color state) 12.7) 255 255) (reset! offset 0)
; (q/stroke-weight 4) (q/with-translation [(/ (q/width) 2)
; Calculate x and y coordinates of the circle. (/ (q/height) 2)]
(let [angle (:angle state) (doseq [i (range 0 (q/width) w)]
x (* 150 (q/cos angle)) (let [angle (:angle state)
y (* 150 (q/sin angle)) sin (q/sin (+ angle @offset))
sin (q/sin angle) cos (q/cos angle)
cos (q/cos angle) h (q/map-range sin -1 1 10 w)]
h (q/map-range sin -1 1 10 40) (q/rect (- (/ (q/width) 2) i) 0 (- w 2) h)
w (q/map-range cos -1 1 10 40)] (swap! offset + 0.5)))))
; Move origin point to the center of the sketch.
(q/with-translation [(/ (q/width) 2)
(/ (q/height) 2)]
(doseq [i (range 1 48)]
(q/fill (q/map-range i 1 48 0 255) 255 255)
(q/with-rotation [(/ q/TWO-PI i)]
(q/rect 0 (* 2 h) (- 41 w) h)
; (q/rect 0 (* -2 w) w (- 41 h))
; (q/rect (* -2 w) 0 w h)
(q/rect (* 2 h) 0 (- 41 w) (- 41 h)))))))
; Draw the circle.
; (q/ellipse x y 100 100))))
(q/defsketch cubes (q/defsketch cubes
:title "You spin my circle right round" :title "You spin my circle right round"