I am trying to learn clojure and quil to replace my current Processing workflow. So, apologies if I am asking obvious questions.
I am not getting why this sketch isn't working. When I make a fake "state" map in the REPL and test the functions they seem to produce what I want...
I define :pts in setup (get-pts returns a vector of tuples like [[100 100] [200 200] [123 456]])
(defn setup [] (q/frame-rate 30) (q/color-mode :hsb) {:color 0 :angle 0 :pts get-pts})Then in update-state, I try to update :pts by mapping an update function to all the pts. (update-pt adds to a passed-in tuple)
(defn update-state [state]
{:color (mod (+ (:color state) 0.7) 255)
:angle (+ (:angle state) 0.1)
:pts (update-in state [:pts] #(mapv update-pt %1))})
Then, down in the draw-state function, I have this:
(let [pts (:pts state)]
(doseq [pt pts]
(apply #(q/rect %1 %2 50 50) pt)))
I don't get any rectangles. If I replace the (:pts state) with a manual vector of pts, or even the (get-pts) function, I get the rectangles. But then they obviously don't get updated as the state changes...
Also, if I comment out the :pts part in the update-state function, I still don't get rectangles. It's like the draw function doesn't even see the (:pts state) result.
So, what am I doing wrong? Any help would be appreciated!
Jason