Fork me on GitHub
#quil
<
2019-04-29
>
Eric Ervin00:04:10

Hey, @theeternalpulse, I was just practicing quil rewriting one of your clojure2d experiments. Learned a couple tricks. https://github.com/ericcervin/quil-practice/blob/master/src/quil_practice/quilpractice20190428.clj

theeternalpulse01:04:36

oh, haven't seen that one in a while. I need to get back into reading euclid's elements.

theeternalpulse01:04:14

Also for this I was also experimenting with instead of an update function mapped over a collection of drawn objects, I use an infinite sequence with hte update function passed to iterate. I don't think it's very common and it seems awkward. I also don't know if performance wise it's any better, but since it's lazily evaluated I imagine it's not far off. I think doing it this way is a bit awkward.

Eric Ervin02:04:05

When I've done similar orbiting circles, I can figure our the position of the orbiter with it's speed, orbit size, and the frame-count. Does clojure2d have something like frame-count that keeps track of how long the sketch has been running?

;;moon
    (let [rads (q/radians (* (q/frame-count) (:o-rate ptd))) 
          ht (+ (:y ptd) (* (q/sin rads) (/ (:o-diameter ptd) 2)))
          wt (+ (:x ptd) (* (q/cos rads) (/ (:o-diameter ptd) 2)))]
          
         (q/fill (+ 100 (rand-int 155)) (+ 100 (rand-int 155)))
         (q/ellipse wt ht 10 10)))
The whole mess is here: https://github.com/ericcervin/cat-tv/blob/master/src/cat_tv/cattv_20170317.clj And here it is in P5.js . Cats love it. https://ericcervin.github.io/cattv_20170317.html

genmeblog08:04:07

@ericcervin drawing function receives frame number as third parameter. In Clojure2d.

Eric Ervin19:04:27

Ah. I see. Good stuff.

:draw-fn - drawing function, called before every display refreshment. Function should accept following four parameters:
    canvas within graphical context (you don’t need to use with-canvas or with-canvas-> wrappers.
    window object
    current frame number as a long value
    current state

👍 1