Line Breaks and nan Values - Quartz Composer Tutorial

One thing that has vexed programs that I've seen that use Javascript structure for line drawing, is a that I have NEVER seen a way to draw non-contiguous lines, though I've seen some close attempts that seem to "latch" to the last point drawn.

Recently, I had a pretty obvious solution to this come to mind, at a time when I wasn't even programming.

When one constructs a queue of values, let's say x, y, z, for the sake of argument, and use a structure render of some type (or even an iterator setup), there is seemingly no way to make a "pen up" movement, and "pen down", so that the line strips (or quads, points, etc.), actually responds like a pen.

I've done similar concepts with feedback rendering, but it always bothered me to have to resort to feedback.

The solution is to feed the values of your structure queue with a nan value whenever your primary mouse key is not being pushed. This is extremely simple. All one has to do is make number multiplexers, place nan in position 0, and then place your X, Y, and Y scroll (for Z), into the secondary inputs. In fact, all one has to do is to do this with one of the variables; I simply do this with all because I like the uniformity of it. Whenever the nan is pushed to the Queue, nothing is rendered. This gives the effect of "pen up"/pen down" without a whole new line being drawn every time.

Taking this one step further, with the correct "splice" setup with the javascript, one can setup the secondary button on a mouse so that it controls a multiplexer that pushes a 0 to the Queue count whenever it is pressed, effectively clearing all previously drawn lines.

I'm including a qtz that demonstrates this theory in the account, "Particle Pen - Non Contiguous Line Writing Example". Please load the most recent version of GL Tools 1.6, available at for this to restore correctly, as I am using a structure render and a stock particle system for the "pen" (not possible with the stock Iterator patch). If not, the javascript queue, mouse control portion should work fine with any scenario where you are something that can render structures, or in scenarios where you use an iterator to iterate the structure for placement.