jsui vs. Window Listener (js + jit.window)
WHY IS JSUI WORKING BETTER?
Both of these patches poll the mouse position at the interval determined by the metro. Currently, up to 200 mouse positions are stored in an array for each—values that are used to draw the line. (And although I realize that this is an inefficient way of doing things, I haven’t come up with a better solution yet…suggestions welcome!) As you might notice, in the jsui patch, it runs pretty smoothly, even as the array of positions fills up. In the listener patch, however, line drawing runs fairly smoothly at the beginning, but towards the end, it lags a lot. It’s horrible. =(
JSUI VS. JIT.WINDOW?
I know that this post is loaded with questions, but any insights to any aspects of this would be greatly appreciated!!!
On Apr 16, 2008, at 8:49 AM, Gracie wrote:
> WHY IS JSUI WORKING BETTER?
> Both of these patches poll the mouse position at the interval
> determined by the metro. Currently, up to 200 mouse positions are
> stored in an array for each—values that are used to draw the
> line. (And although I realize that this is an inefficient way of
> doing things, I haven’t come up with a better solution
> yet…suggestions welcome!) As you might notice, in the jsui
> patch, it runs pretty smoothly, even as the array of positions fills
> up. In the listener patch, however, line drawing runs fairly
> smoothly at the beginning, but towards the end, it lags a lot. It’s
> horrible. =(
Without checking your patch in detail, it sounds like you are
overlooking that jit.gl.sketch builds up a commandlist, so that you
can change the camera position and it redraws everything which has
already been drawn. So every "lineto" or other command appends to an
internal list which probably keeps growing in your instance. You can
either reset the command list with the reset() method each time you
draw, use the immediate attribute, or rely on the previously cached
commandlist rather than a JS array which you keep redrawing.
Hope this helps.
Thanks so much — your post helped immensely!! I was definitely overlooking the commandlist. It was just a matter of adding a line to the window listener code to get it to behave better by leaps and bounds. You’ve saved me a lot of headache. I totally appreciate it! =)
I’m working on something similar in which I use stroke to continuously draw in a jit.gl.sketch.
after a while the patch really slows down, which I guess is due to the commandlist becoming to big. However, using reset isn’t an option.
What would be the best way of keep on drawing continuously, is there an option to disable this build up of the commandlist, while still drawing?
thanks in advance