Line Drawing

jersmi's picture

Working on a comp based on the QC example comp "paint" to draw lines with the mouse on three sprites (one at a time) then move around the sprites. Two questions:

  1. Interaction Is there a way to switch off the interaction patch? I can connect it to a multiplexer but it doesn't seem to do anything.

  2. I'm using the Kineme GL Line patch. Is there a way to draw new lines when the mouse button is released, instead of continuing from the last point?

jersmi's picture
Re: Line Drawing

Forgot to attach comp. (And I'm not sure why the line break disappeared after the word "interaction".)

And one more question: any advise on antialiasing the lines/image produced by the accumulator? The RII supersampling technique doesn't seem to do much in this case.

PreviewAttachmentSize
LineDrawMultiSprite.qtz77.56 KB

dust's picture
Re: Line Drawing

I'm not at my computer so can't look at your example as of right now. but as far as drawing on a sprite and then moving it. that is ooosible but you have to some sort of logic, like middle mouse drag moves sprite. or use a hit test instead of interaction and then do conditional like if hit test is equal to yes and double click equals true then move else draw on sprite if hit test true. as per painting there are a few ways to accumulate. one is the accumulator two is to queue up your images and then iterate through the queue. this is limited to the depth of your queue. my preferred method is to simply put a billboard inside your render in image, then add a filter to output image then feedback that image into your render in image patch. so it's what ever you have in the rii plus a billboard for feed back. as far as the lines are concerned I think you might have better luck with a ribbon style of streak...

jersmi's picture
Re: Line Drawing

Thanks, Dust. Since I started with the Paint.qtz, I committed to the accumulator method and switched out the gaussian blur for the gl line (which i am happy with except for not knowing how to stop / start drawing on mouse click off/on). Looks like I should experiment.

I can set up a sample and hold system with the mouse to move the sprites, I guess. Everyone already has probably given up on the Interaction patch until further dev, eh?

dust's picture
Re: Line Drawing

all i get is a white screen with your patch. having the mouse hooked up to replace content should do the trick but if you noticed with gl lines there is always that connected line meaning when start painting again it draws the line from the last place to the new place. here is a example of how to paint with lines but have them start and stop with the mouse.

PreviewAttachmentSize
linePainter.qtz11.09 KB

jersmi's picture
Re: Line Drawing

Thanks again, Dust. Hitting the 'a' key to exit the 'show all' state should make my patch work. sorry it's unclear -- it's in progress.

And getting values stored for each of the three sprite's X/Y position, etc. is so far tricky. The Interaction patch -- so close.

jersmi's picture
Re: Line Drawing

Hmm, not sure yet how that one can help me, dust. The javascript queue does not work the same way as the QC queues, and i'd have to think how to translate the mesh js patch for the gl line. Clues?

Curious to know if mine will work for you -- might make more sense. should probably post a simpler version to demo, maybe to clear content on the accum, too. This is drawing like the paint.qtz, only the gl line works better, imho, allowing scribbly lines with no "skips". Only I want it to skip when mouse is up.

I want to draw stuff and push the drawings around in space, quickly and efficiently. Then I want to turn the drawings into "wipes" (masks) for video.

usefuldesign.au's picture
Re: Line Drawing

I think you could be better off using Kineme Line Structure patches. It can be set to Line Strip (continuous line drawing from each point to the next) or Line Segments which will give you discrete lines between each pair of consecutive points in the input structure.

If you use Line Segments you can have the gaps you require between paths and where you want continuous lines just repeat the co-ordinate of the second point for item [i] as the first point of item [i+1]. I'd be using javascript to do that based on a mouse down Keyboard Patch trigger. Right mouse down could enable a 'move' mode where the JS patch translates the co-ordinate values according to mouse co-ords or do same thing with a transform patch. Other mouse button could enable a second JS to scale the co-ordinates about the mousedown point(x,y) as origin.

Using modifier keys (Kineme Freeboard patch) you could have pan and scale functions using either method (3d Transform would be faster but the line width would change unless you calibrate and compensate for the z-axis shift. Using modifiers from Freeboard with keys from Keyboard patch is a bit buggy though and I'm not aware of it being fixed (I'm on QC3.0). Keystates jam on like a piano key that doesn't come up. cwright says the bug is in the Keyboard patch and I've logged a radar if I remember correctly.

Line Structure patch is a fair lot faster than iterator in my experience too.

As for using these line as wipes I can't see how that could possibly work unless they were filled in or something (not totally sure how you would do that either) and you scaled them. Do you mean wipes as in A/B video transitions?

dust's picture
Re: Line Drawing

I'm pretty sure I tried hitting a for view all. I'm still interested to see yup painting on particular objects. as per interactions they are awesome. I think one of the harder things about qc at first is moving a sprite around the screen for placement. doing this with numerals is tricky. I have got the hang of of it and often forget I can switch on the interaction mode in the viewer and just drag things around like you would find in a normal drawing package I guess. interation mode is the little arrow crosshairs mover icon in the viewer. I personally use the interaction mode when I can remember. I'm thinking in your project your going to want more flexibility with your interactions there for I suggest using the hit test patch. with it you can program interactions. I'm not sure if interactions are new new in x code but now you can set any view image layer etc... to intractable and do a whole host of things to them that normally had to be done with the hit tester. as per the lines it's line segments you want to draw with as useful design stated. at least that's how you would do with core graphics which seems to be just a layer onto of gl.

jersmi's picture
Re: Line Drawing

Okay, cool. I started with mods to the paint.qtz but looks like I could be in for some restructuring. The thing is, this drawing setup uses like three iterations of the GL Line (n, n-1, n-2) to do the job, so the Line Structure patch seemed like overkill. But maybe that's the way.

As far as "wipes", I really mean luma key, as in draw in white on top layer, mask to alpha, invert or not, etc., and let the bottom layer show through. That one I think I got, just sharing...

jersmi's picture
Re: Line Drawing

Well, it turned out to be super easy to get new lines on mouse click with a js queue and line structure patch. Thanks again.

And dust, I had never used the interaction viewer mode -- cool! still, i want this to be part of the patch, accessible with the mouse or whatever input. so i'll have a look at the hit test patch, i guess. The interaction patch could be cool...

also, for now i think i fixed it so the patch is in drawing mode on startup.

PreviewAttachmentSize
LineDrawMultiSprite2.qtz65.52 KB

jersmi's picture
Re: Line Drawing

Oh, yeah, usefuldesign.au, I could see using the 3D transform patch with key strokes, but it seemed more direct for my needs using the sprite settings. But it'd be much more spatial with the 3D transform. I keep thinking about that patch cwright posted (in response to i don't remember who) a few months back on drawing in 2D then moving the line into 3D space. That one is nice...

Another question: I'd like to draw on sprites then render using QuartzCrystal. How can I save a .qtz with drawings? Now it looks like the Accumulator might not be the way to go, unless I use something like the dreaded Value Historian...

jersmi's picture
Re: Line Drawing

And one more question. I think I read this and the answer is no -- any way to get pen pressure input from a wacom bamboo for line width and/or alpha?