2d wave edition
This commit is contained in:
parent
6d40c5695a
commit
26dade3b0f
|
@ -22,32 +22,22 @@
|
|||
{:color (mod (+ (:color state) 0.7) 255)
|
||||
:angle (+ (:angle state) 0.1)})
|
||||
|
||||
(def w 50)
|
||||
(def offset (atom 0))
|
||||
|
||||
(defn draw-state [state]
|
||||
; Set circle color.
|
||||
(q/background 0)
|
||||
(q/fill (:color state) 255 255)
|
||||
(q/stroke (- (:color state) 12.7) 255 255)
|
||||
; (q/stroke-weight 4)
|
||||
; Calculate x and y coordinates of the circle.
|
||||
(let [angle (:angle state)
|
||||
x (* 150 (q/cos angle))
|
||||
y (* 150 (q/sin angle))
|
||||
sin (q/sin angle)
|
||||
cos (q/cos angle)
|
||||
h (q/map-range sin -1 1 10 40)
|
||||
w (q/map-range cos -1 1 10 40)]
|
||||
; Move origin point to the center of the sketch.
|
||||
(reset! offset 0)
|
||||
(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))))
|
||||
(doseq [i (range 0 (q/width) w)]
|
||||
(let [angle (:angle state)
|
||||
sin (q/sin (+ angle @offset))
|
||||
cos (q/cos angle)
|
||||
h (q/map-range sin -1 1 10 w)]
|
||||
(q/rect (- (/ (q/width) 2) i) 0 (- w 2) h)
|
||||
(swap! offset + 0.5)))))
|
||||
|
||||
(q/defsketch cubes
|
||||
:title "You spin my circle right round"
|
||||
|
|
Loading…
Reference in a new issue