quil

2019-04-29T00:04:10.008800Z

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

theeternalpulse 2019-04-29T01:14:36.009800Z

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

theeternalpulse 2019-04-29T01:21:14.012100Z

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.

2019-04-29T02:16:05.023500Z

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

genmeblog 2019-04-29T08:15:07.025Z

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

2019-04-29T19:12:27.026400Z

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