Drawing like with a pen (subpixel)

Mar 18, 2007 at 11:23pm

Drawing like with a pen (subpixel)

Hi community,
I still haven’t really solved my problem with drawing in Jitter. Maybe to explain it a little bit better what I want to do finally: With the help of a webcam I want to draw some forms in a jit.window. A coloured point in the movie gives me with the jit.getbounds operations coordinates. With these I would like to redraw the movement of the coloured point. My patch is working so far, but instead of a line, I only get individual points (because I am using a sphere to draw). It would be alright to draw with these points, but I don’t really get a nice dash! There is just one point after another.
Would it be possible to draw in a jit.window like with a pen? I know, that I can draw with the mouse, but I wanted to draw with these given coordinates!
I also heard something about ‘Subpixel-Rendering’ but in the archives I didn’t get some information about that.
I know, that my problem is a little bit weird, but maybe somebody would have just ANY help, a link or some patches which could help me!!
Thanks a lot,
Johannes

#30905
Mar 19, 2007 at 2:09am

If you posted a simple patch that would be helpful. You probably want
to use jit.lcd for drawing and overlay the result on the window. Hard
to say though without seeing exactly what you’re doing.

wes

On 3/18/07, Johannes wrote:
>
> Hi community,
> I still haven’t really solved my problem with drawing in Jitter. Maybe to explain it a little bit better what I want to do finally: With the help of a webcam I want to draw some forms in a jit.window. A coloured point in the movie gives me with the jit.getbounds operations coordinates. With these I would like to redraw the movement of the coloured point. My patch is working so far, but instead of a line, I only get individual points (because I am using a sphere to draw). It would be alright to draw with these points, but I don’t really get a nice dash! There is just one point after another.
> Would it be possible to draw in a jit.window like with a pen? I know, that I can draw with the mouse, but I wanted to draw with these given coordinates!
> I also heard something about ‘Subpixel-Rendering’ but in the archives I didn’t get some information about that.
> I know, that my problem is a little bit weird, but maybe somebody would have just ANY help, a link or some patches which could help me!!
> Thanks a lot,
> Johannes
>

#99485
Mar 19, 2007 at 9:06am

Hello Wes,
thanks for your answer! Of course with a patch it’s maybe easier to understand. I rewrote my patch a bit more simple.
To explain:
The camera (resolution 320*240, very poor, I know…) catches the movement of a red object (jit.findbounds).
I change the volumes of brightness, contrast and saturation with jit.brcosa to find the color more easily.
I calculate the center of the red object and create a very small sphere at that point (jit.gl.gridshape).
When I move now the object, I create a sphere at every given point by findbounds. If it works well, I sometimes get nice dashes, but normally I just arrive to draw one dot after another! I could call it a dash, but I am looking for something more proper.
Maybe you, or anybody could understand, what I meen ;)
I am still at the beginning of working with Max/MSP/Jitter, so if I put my words in an uncomprehensible way, don’t hesitate to do some critics!!
Thanks,
Johannes

#99486
Mar 19, 2007 at 9:14am

Hi again,
just looked at jit.lcd!
Thanks, Wes, maybe this could really help me! In fact, I don’t want to draw with the mouse, but I will have a look at that command, and hope to find somethink useful…
Greets,
Johannes

#99487
Mar 19, 2007 at 2:07pm

if you want to remain in opengl land, check the twineball recipe for curve
drawing in sketch or the etch-a-sketch example.
problem with this method is that if you dont manage your cmd-list or move it
to displaylist mode, this can get heavy on the card.

On 3/19/07, Johannes wrote:
>
>
> Hi community,
> I still haven’t really solved my problem with drawing in Jitter. Maybe to
> explain it a little bit better what I want to do finally: With the help of a
> webcam I want to draw some forms in a jit.window. A coloured point in the
> movie gives me with the jit.getbounds operations coordinates. With these I
> would like to redraw the movement of the coloured point. My patch is working
> so far, but instead of a line, I only get individual points (because I am
> using a sphere to draw). It would be alright to draw with these points, but
> I don’t really get a nice dash! There is just one point after another.
> Would it be possible to draw in a jit.window like with a pen? I know, that
> I can draw with the mouse, but I wanted to draw with these given
> coordinates!
> I also heard something about ‘Subpixel-Rendering’ but in the archives I
> didn’t get some information about that.
> I know, that my problem is a little bit weird, but maybe somebody would
> have just ANY help, a link or some patches which could help me!!
> Thanks a lot,
> Johannes
>

#99488
Mar 19, 2007 at 2:59pm

yair reshef skrev:
> if you want to remain in opengl land, check the twineball recipe for
> curve drawing in sketch or the etch-a-sketch example.
> problem with this method is that if you dont manage your cmd-list or
> move it to displaylist mode, this can get heavy on the card.
>
Hello Yair,
can you expand on this a bit? I’ve dealt with automatic thinning of the
cmd-list before, and I really didn’t care for it ;) Displaylist mode,
however, is something I’ve never gotten into.

cheers,
Andreas.

#99489
Mar 20, 2007 at 11:46am

yair reshef skrev:
> if you want to remain in opengl land, check the twineball recipe for
> curve drawing in sketch or the etch-a-sketch example.
> problem with this method is that if you dont manage your cmd-list or
> move it to displaylist mode, this can get heavy on the card.
>
Weird, my emails to this list yesterday got completely lost. Anyway,
Yair, could you elaborate a bit on the display list mode? I’ve not gone
down that road before.

cheers,
Andreas.

#99490
Mar 20, 2007 at 12:08pm

as far as my understanding goes, displaylist stores drawing commands
(glcolor, glvertex etc.) on the card.
in effect freezing its state and so no new commands are sent. all is on the
card. makes the cpu happy.
i have seen several web references to manipulating stored lists. i dont know
if and who to do it in jitter.

On 3/20/07, Andreas Wetterberg wrote:
>
> yair reshef skrev:
> > if you want to remain in opengl land, check the twineball recipe for
> > curve drawing in sketch or the etch-a-sketch example.
> > problem with this method is that if you dont manage your cmd-list or
> > move it to displaylist mode, this can get heavy on the card.
> >
> Weird, my emails to this list yesterday got completely lost. Anyway,
> Yair, could you elaborate a bit on the display list mode? I’ve not gone
> down that road before.
>
> cheers,
> Andreas.
>

#99491
Mar 23, 2007 at 11:38am

Hi there,
I’ve looked a little bit on the attribute “displaylist” but couldn’t find anything for managing it in the tutorials! Can anybody give me a hint on how to use this attribute? I have recognized, that my patch works really hard on my CPU, so this would be really useful.
Like Andreas, I am also not very well informed about managing my cmd-list! Just some patches or other informations could really save my CPU!!;)
Thanks a lot,
Johannes

#99492
Mar 23, 2007 at 5:08pm

as far as i can tell, displaylist is just and only a toggle. on and off.
i’d love to hear differently.
managing cmd_list is a problem we all share.
all i saw from myself and from other maxers who use cmd_lists involve a lot
of jit.iter, plain iter colls and many many bangs..
we still use this method as its the most flixble way for dealing with opengl
commands i know of.
i can post a subpatch with one but its nothing involving display_lists.
the main trick is to keep the number of lines in the cmd_list within your
graphic card capabilities.
erase some lines or reset completely and redraw the while batch.
my cards where not happy cmd_list with more then say… 215 quads with video
texture applied.

On 3/23/07, Johannes wrote:
>
>
> Hi there,
> I’ve looked a little bit on the attribute “displaylist” but couldn’t find
> anything for managing it in the tutorials! Can anybody give me a hint on how
> to use this attribute? I have recognized, that my patch works really hard on
> my CPU, so this would be really useful.
> Like Andreas, I am also not very well informed about managing my cmd-list!
> Just some patches or other informations could really save my CPU!!;)
> Thanks a lot,
> Johannes
>

#99493
Mar 23, 2007 at 5:33pm

If you go into the hundreds of quads realm with calls to glVertex,
it’s safe to say your performance will start to suffer. The solution
is vertex buffers which are supported by jit.gl.mesh. Unfortunately,
not all scenarios lend themselves to being rendered by matrices. I
would think JS would be a good way to manage opengl commands because
it’s something that lends itself to typical OO or procedural
techniques. There’s also jit.gl.lua by the way. In Lua functions are
first class values meaning you can store them as variables and
generate new ones, meaning you can do stuff like this:

function draw()
gl.Begin(“LINES”)
drawVertices()
gl.End()
end

function drawVertices()
gl.Vertex(-1, 0, 0)
gl.Vertex(1, 0, 0)
end

function addLine(x1, y1, z1, x2, y2, z2)
local drawFunc = drawVertices
drawVertices = function()
gl.Vertex(x1, y1, z1)
gl.Vertex(x2, y2, z2)
drawFunc()
end
end

Of course this code doesn’t allow you to remove specific vertices or
save them later, but that could be remedied by saving the functions in
a table instead of in a function.

wes

#99494
Mar 28, 2007 at 1:44pm

Hi there,
well I searched a little bit more about drawing lines with the help of your hints (THANKS A LOT!!)and so I created this posted patch.
I am not quite sure, if I understood everything well, about saving CPU and “displaylist”: Just to disable could save my CPU?
Also my cmd-list worries me a bit! Maybe someone could have a look on the patch? Some hints to make it better would be great!!
Thans a lot,
Johannes

#99495
Mar 28, 2007 at 2:42pm

any chance you could either zip it up or paste it as text in an email.
Patches attached directly always seem to get corrupted for me.

wes

On 3/28/07, Johannes wrote:
> Hi there,
> well I searched a little bit more about drawing lines with the help of your hints (THANKS A LOT!!)and so I created this posted patch.
> I am not quite sure, if I understood everything well, about saving CPU and “displaylist”: Just to disable could save my CPU?
> Also my cmd-list worries me a bit! Maybe someone could have a look on the patch? Some hints to make it better would be great!!
> Thans a lot,
> Johannes
>
>
>
>

#99496
Mar 28, 2007 at 3:54pm

Hi Wesley!
Here is the patch in text-form and also in Zip-version. I hope it will work like that! If not, just tell me and I will send an email directely to you with everything in it.
Greetings,
Johannes

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 792 852 26 9109513 print;
#P toggle 788 776 15 0;
#P toggle 789 733 15 0;
#P message 788 797 64 9109513 getcmdlist $1;
#P message 789 753 63 9109513 displaylist $1;
#P window setfont “Sans Serif” 14.;
#P comment 336 610 128 9109518 Create the lines;
#P window setfont “Sans Serif” 9.;
#P number 686 657 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 644 721 61 9109513 pack 0. 0. 0.;
#P message 644 745 69 9109513 lineto $1 $2 $3;
#P toggle 663 766 15 0;
#P message 663 795 76 9109513 depth_enable $1;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 349 468 182 9240586 jit.window etcha 5 41 645 501;
#B color 5;
#P user panel 344 461 193 32;
#X brgb 149 197 161;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 462 702 62 9109513 turn antialiasing on/off;
#P toggle 462 748 15 0;
#P window linecount 2;
#P message 462 774 79 9109513 antialias $1 , blend_enable $1;
#P window linecount 1;
#P hidden message 566 771 50 9109513 set 0;
#P hidden newex 489 746 50 9109513 t b;
#P newex 686 682 35 9109513 / 256.;
#P newex 567 684 35 9109513 / 256.;
#P user jit.fpsgui 392 739 60 9109513 0;
#P newex 348 680 43 9109513 jit.qball;
#P number 393 631 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 348 631 15 0;
#P newex 348 657 55 9109513 metro 20;
#P newex 348 711 55 9109513 t b erase b;
#P newex 577 825 158 9109513 jit.gl.sketch etcha @color 0. 0. 0. 1.;
#P newex 348 824 199 9109513 jit.gl.render etcha @erase_color 0.7 0.7 0.7 1.;
#P window setfont “Sans Serif” 18.;
#P message 553 713 61 9109522 reset;
#P window setfont “Sans Serif” 9.;
#P newex 686 614 67 9109513 expr ($f1-120);
#P flonum 567 547 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 567 615 67 9109513 expr ($f1-160);
#P comment 568 567 48 9109513 horizontal;
#P comment 738 568 41 9109513 vertical;
#P comment 686 458 34 9109513 bottom;
#P comment 649 458 24 9109513 right;
#P comment 612 458 24 9109513 top;
#P comment 573 458 24 9109513 left;
#P window setfont “Fixedwidth Serif” 10.;
#P number 744 546 35 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 567 485 140 9240586 expr $i1+(($i2-$i1)/2);
#P newex 606 511 173 9240586 expr 239-($i1+(($i2-$i1)/2));
#P window setfont “Sans Serif” 9.;
#P number 684 432 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 645 432 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 606 432 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 567 432 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 645 399 38 9109513 unpack;
#P newex 567 400 38 9109513 unpack;
#P message 182 472 30 9109513 close;
#P message 115 479 28 9109513 open;
#P toggle 22 466 15 0;
#P newex 22 494 40 9109513 metro 2;
#P newex 22 530 85 9109513 jit.dx.grab 320 240;
#P window setfont “Proportional Serif” 10.;
#P comment 430 390 96 9175050 Show Tracked Region;
#P comment 419 268 110 9175050 Track a Color Range;
#P window setfont “Fixedwidth Serif” 10.;
#P user ubumenu 568 276 140 9240586 0 1 1 0;
#X add 0 = Produce No Sound;
#X add 1 = Play MIDI Notes;
#X add 2 = Play MSP Tones;
#X prefix_set 0 0 0;
#X pattrmode 1;
#P window linecount 2;
#N vpatcher 235 227 784 539;
#P origin -68 -16;
#P window setfont “Proportional Serif” 10.;
#P comment 295 94 28 9175050 Freq.;
#P comment 128 94 28 9175050 Freq.;
#P window setfont “Fixedwidth Serif” 10.;
#P number 258 94 37 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 26 43 241 9240586 unpack 0 0 0 0;
#P number 91 94 37 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Proportional Serif” 10.;
#P comment 112 167 83 9175050 Add a little vibrato;
#P comment 41 22 206 9175050 Use horizontal and vertical location as frequencies;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 210 164 63 9240586 *~;
#P newex 210 141 50 9240586 *~ 0.02;
#P newex 193 114 38 9240586 line~;
#P newex 193 93 62 9240586 pack 0 50;
#P newex 193 187 27 9240586 +~;
#P newex 193 210 43 9240586 cycle~;
#P newex 263 141 53 9240586 cycle~ 5;
#P newex 193 68 200 9240586 expr (239-($i1+(($i2-$i1)/2)))*7;
#P newex 43 164 63 9240586 *~;
#P newex 43 141 50 9240586 *~ 0.02;
#P newex 26 114 38 9240586 line~;
#P newex 26 93 62 9240586 pack 0 50;
#P newex 26 68 164 9240586 expr ($i1+(($i2-$i1)/2))*5;
#P newex 26 187 27 9240586 +~;
#P newex 26 210 43 9240586 cycle~;
#P newex 96 141 68 9240586 cycle~ 4.5;
#P newex 328 112 26 9240586 b 1;
#P newex 243 244 27 9240586 *~;
#P newex 293 244 27 9240586 *~;
#P message 398 167 32 9240586 stop;
#P message 398 244 14 9240586 0;
#P message 382 244 14 9240586 1;
#P newex 398 192 68 9240586 delay 1000;
#P newex 469 167 62 9240586 delay 201;
#P message 469 192 50 9240586 0. 1000;
#P message 328 167 53 9240586 0.5 1000;
#P newex 328 141 62 9240586 onebang 1;
#P newex 328 217 38 9240586 line~;
#P newex 243 269 60 9240586 dac~;
#N comlet rectangle from jit.findbounds;
#P inlet 26 21 15 0;
#P window setfont “Proportional Serif” 10.;
#P comment 358 107 93 9175050 Turn DSP on/off and fade sound in/out;
#P connect 1 0 34 0;
#P connect 34 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 20 0;
#P connect 20 0 17 0;
#P connect 17 0 16 0;
#P fasten 20 0 21 0 31 136 48 136;
#P connect 21 0 22 0;
#P connect 22 0 17 1;
#P fasten 18 0 33 0 31 89 96 89;
#P connect 15 0 22 1;
#P connect 34 2 18 1;
#P fasten 34 1 23 0 108 64 198 64;
#P connect 23 0 27 0;
#P connect 27 0 28 0;
#P connect 28 0 26 0;
#P connect 26 0 25 0;
#P fasten 28 0 29 0 198 136 215 136;
#P connect 29 0 30 0;
#P connect 30 0 26 1;
#P fasten 16 0 13 0 31 236 248 236;
#P connect 13 0 2 0;
#P fasten 9 0 2 0 387 265 248 265;
#P fasten 10 0 2 0 403 265 248 265;
#P fasten 23 0 35 0 198 89 263 89;
#P fasten 3 0 13 1 333 239 265 239;
#P connect 24 0 30 1;
#P fasten 25 0 12 0 198 231 298 231;
#P connect 12 0 2 1;
#P fasten 3 0 12 1 333 239 315 239;
#P fasten 1 0 14 0 31 39 396 39 396 89 333 89;
#P connect 14 0 4 0;
#P connect 4 0 5 0;
#P fasten 6 0 3 0 474 213 333 213;
#P connect 5 0 3 0;
#P fasten 7 0 4 1 474 188 465 188 465 137 385 137;
#P fasten 4 0 9 0 333 162 387 162;
#P fasten 34 3 23 1 262 64 388 64;
#P fasten 4 0 11 0 333 162 403 162;
#P fasten 7 0 8 0 474 188 403 188;
#P connect 11 0 8 0;
#P connect 8 0 10 0;
#P fasten 14 0 7 0 333 133 474 133;
#P connect 7 0 6 0;
#P pop;
#P newobj 631 344 60 9240586 patcher playtones;
#P window linecount 1;
#P newex 568 323 73 9240586 gate 2;
#P newex 631 302 80 9240586 pack 0 0 0 0;
#P window linecount 2;
#N vpatcher 381 48 730 311;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 77 52 112 9240586 unpack 0 0 0 0;
#P window setfont “Proportional Serif” 10.;
#P comment 94 35 148 9175050 Use coordinates to play MIDI notes;
#P comment 158 144 40 9175050 velocity;
#P comment 49 144 28 9175050 pitch;
#P comment 145 109 119 9175050 put in usable velocity range;
#P comment 1 125 72 9175050 look up in scale;
#P comment 1 104 75 9175050 ignore duplicates;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 77 81 170 9240586 expr ($i1+(($i2-$i1)/2))/16;
#P newex 123 123 200 9240586 expr (239-($i1+(($i2-$i1)/2)))/2;
#P newex 77 187 62 9240586 noteout a;
#P newex 77 162 102 9240586 makenote 100 200;
#P number 123 144 35 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 77 144 35 10 0 0 256 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 77 102 44 9240586 change;
#N vtable 20 40 55 250 222 980020 128;
#T set 0 24 36 43 48 52 55 58 60 63 65 67 70 72 75 77 78 79 81 82 84;
#P newobj 77 123 38 9240586 table;
#N comlet rectangle from jit.findbounds;
#P inlet 77 34 15 0;
#P window setfont “Proportional Serif” 10.;
#P comment 1 83 76 9175050 put in range 0-19;
#P connect 1 0 16 0;
#P connect 16 0 9 0;
#P connect 9 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P fasten 6 1 7 1 174 183 108 183;
#P fasten 16 1 8 0 116 77 128 77;
#P connect 8 0 5 0;
#P connect 5 0 6 1;
#P fasten 16 2 9 1 150 77 242 77;
#P fasten 16 3 8 1 184 73 318 73;
#P pop;
#P newobj 568 344 60 9240586 patcher playnotes;
#P user jit.pwindow 349 378 82 62 0 1 0 0 1 0;
#P window linecount 1;
#P newex 350 356 68 9240586 jit.matrix;
#P newex 413 302 110 9240586 prepend srcdimend;
#P toggle 437 352 15 0;
#P objectname usesrcdim;
#P message 437 370 80 9240586 usesrcdim $1;
#P newex 360 327 122 9240586 prepend srcdimstart;
#P window linecount 3;
#P newex 360 215 116 9240586 jit.findbounds @min 0. 0.9 0. 0. @max 1. 1. 0. 0.;
#B color 5;
#P user jit.pwindow 16 199 322 242 0 1 0 0 1 0;
#P window linecount 1;
#P message 321 116 83 9240586 saturation $1;
#P flonum 321 98 35 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname saturation;
#P message 235 116 73 9240586 contrast $1;
#P flonum 235 98 35 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname contrast;
#P message 149 116 83 9240586 brightness $1;
#P flonum 149 98 35 10 0 0 0 141 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname brightness;
#P newex 17 140 68 9240586 jit.brcosa;
#P user panel 565 271 149 108;
#X brgb 255 127 255;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 12.;
#P comment 565 254 160 9109516 Use Tracking Info for Sound;
#P user panel 345 215 182 229;
#X brgb 127 255 255;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 144 91 265 46;
#X brgb 127 255 127;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 9.;
#P comment 144 76 188 9109513 settings for color-management;
#P user panel 565 399 219 192;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P number 567 653 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 565 383 137 9109513 Calculation for center of region;
#P user panel 336 610 426 255;
#X brgb 255 251 43;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 18.;
#P window linecount 5;
#P comment 767 613 100 9109522 Could this area maybe help me , to save some CPU?;
#P user panel 765 609 113 271;
#X brgb 255 125 125;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P fasten 58 0 84 0 582 848 797 848;
#P connect 82 0 80 0;
#P connect 83 0 81 0;
#P fasten 43 0 44 1 689 451 774 451;
#P fasten 44 0 46 0 611 536 749 536;
#P fasten 42 0 45 1 650 456 702 456;
#P connect 78 0 66 0;
#P fasten 68 0 4 0 571 793 633 793 633 645 572 645;
#P fasten 68 0 58 0 571 793 582 793;
#P fasten 68 0 78 0 571 793 633 793 633 645 691 645;
#P connect 55 0 78 0;
#P fasten 46 0 55 0 749 593 691 593;
#P fasten 39 1 43 0 678 425 689 425;
#P connect 19 1 23 0;
#P fasten 19 1 39 0 418 264 551 264 551 394 650 394;
#P fasten 19 1 27 2 418 294 682 294;
#P fasten 66 0 77 1 691 709 674 709;
#P connect 75 0 74 0;
#P connect 39 0 42 0;
#P connect 77 0 76 0;
#P fasten 65 0 77 0 572 710 649 710;
#P connect 28 1 29 0;
#P connect 27 0 28 1;
#P connect 19 0 20 0;
#P fasten 19 0 38 0 365 285 535 285 535 394 572 394;
#P fasten 19 0 27 0 365 298 636 298;
#P connect 41 0 44 0;
#P fasten 38 1 41 0 600 425 611 425;
#P fasten 56 0 67 0 558 745 494 745;
#P fasten 56 0 58 0 558 797 582 797;
#P fasten 76 0 58 0 649 797 582 797;
#P fasten 74 0 58 0 668 819 582 819;
#P fasten 69 0 58 0 467 811 582 811;
#P fasten 81 0 58 0 793 819 582 819;
#P fasten 80 0 58 0 794 773 777 773 777 819 582 819;
#P connect 28 0 26 0;
#P connect 30 0 28 0;
#P connect 4 0 65 0;
#P connect 53 0 4 0;
#P connect 54 0 53 0;
#P connect 45 0 54 0;
#P connect 40 0 45 0;
#P connect 38 0 40 0;
#P fasten 67 0 68 0 494 766 571 766;
#P connect 70 0 69 0;
#P connect 22 0 21 0;
#P connect 62 0 60 1;
#P connect 59 2 64 0;
#P connect 11 0 18 0;
#P fasten 11 0 24 0 22 161 355 161;
#P fasten 11 0 19 0 22 161 365 161;
#P connect 24 0 25 0;
#P fasten 20 0 24 0 365 348 355 348;
#P fasten 23 0 24 0 418 323 355 323;
#P fasten 21 0 24 0 442 389 433 389 433 352 355 352;
#P fasten 59 1 57 0 375 769 353 769;
#P connect 59 0 57 0;
#P connect 63 0 59 0;
#P connect 60 0 63 0;
#P connect 61 0 60 0;
#P connect 16 0 17 0;
#P connect 14 0 15 0;
#P connect 12 0 13 0;
#P connect 34 0 33 0;
#P fasten 36 0 33 0 120 519 27 519;
#P fasten 37 0 33 0 187 516 27 516;
#P connect 35 0 34 0;
#P fasten 13 0 11 0 154 136 22 136;
#P fasten 15 0 11 0 240 136 22 136;
#P fasten 17 0 11 0 326 136 22 136;
#P fasten 33 0 11 0 27 563 3 563 3 135 22 135;
#P window clipboard copycount 85;

#99497
Mar 28, 2007 at 5:59pm

This is a tricky problem. The displaylist attribute will cause all
commands in a sketch to be built into a displaylist on draw. If you
add new commands, you will trigger a rebuild of the displaylist. This
could potentially cause large drops in framerate.

An alternate solution would be to accumulate the lines in a matrix and
draw them with jit.gl.mesh @draw_mode line_strip. You would keep
track of the last cell containing a point and use jit.submatrix to
send only those cells with data in them to the mesh object. The
drawback with this method is that you’ll have a fixed sized buffer of
lines and have to handle the wrapping case when the counter goes back
to 0.

Also, jit.pwindow eats up quite a bit of CPU. If you don’t need it in
your final patch, I wouldn’t use it.

wes

#P window setfont “Sans Serif” 9.;
#P number 620 658 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 591 682 33 196617 clear;
#P message 742 714 50 196617 dim $1 0;
#P newex 669 605 29 196617 t b f;
#P message 669 684 153 196617 setcell $1 0 val $2 $3 $4 , bang;
#P newex 669 662 75 196617 pack 0 0. 0. 0.;
#P newex 591 738 70 196617 jit.submatrix;
#P newex 591 759 195 196617 jit.gl.mesh etcha @draw_mode line_strip;
#P newex 591 711 136 196617 jit.matrix 3 float32 1000 1;
#N counter 0 0 1000;
#X flags 0 0;
#P newobj 669 632 89 196617 counter 0 0 1000;
#P newex 55 673 64 196617 jit.op @op ~;
#P flonum 241 574 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 241 595 42 196617 rate $1;
#P message 129 558 76 196617 read bball.mov;
#P message 175 595 27 196617 stop;
#P message 141 595 31 196617 start;
#P flonum 84 574 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 42 574 15 0;
#P newex 42 594 52 196617 metro 30;
#P message 205 595 31 196617 clear;
#P newex 42 621 103 196617 jit.qt.movie 320 240;
#P window setfont “Sans Serif” 14.;
#P comment 345 487 128 196622 Create the lines;
#P window setfont “Sans Serif” 9.;
#P number 695 534 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 358 345 182 1441802 jit.window etcha 5 41 645 501;
#B color 5;
#P user panel 353 338 193 32;
#X brgb 149 197 161;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P toggle 471 625 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P message 471 651 79 196617 antialias $1 , blend_enable $1;
#P window linecount 1;
#P newex 695 559 35 196617 / 256.;
#P newex 576 561 35 196617 / 256.;
#P user jit.fpsgui 401 616 60 196617 0;
#P newex 357 557 43 196617 jit.qball;
#P number 402 508 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 357 508 15 0;
#P newex 357 534 55 196617 metro 20;
#P newex 357 588 55 196617 t b erase b;
#P newex 357 701 228 196617 jit.gl.render etcha @erase_color 0.7 0.7 0.7 1.;
#P newex 695 491 86 196617 expr ($f1-120);
#P flonum 576 424 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 576 492 86 196617 expr ($f1-160);
#P comment 577 444 62 196617 horizontal;
#P comment 747 445 41 196617 vertical;
#P comment 695 335 48 196617 bottom;
#P comment 658 335 38 196617 right;
#P comment 621 335 24 196617 top;
#P comment 582 335 24 196617 left;
#P window setfont “Fixedwidth Serif” 10.;
#P number 753 423 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 576 362 140 1441802 expr $i1+(($i2-$i1)/2);
#P newex 615 388 173 1441802 expr 239-($i1+(($i2-$i1)/2));
#P window setfont “Sans Serif” 9.;
#P number 693 309 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 654 309 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 615 309 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 576 309 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 654 276 38 196617 unpack;
#P newex 576 277 38 196617 unpack;
#P message 191 349 30 196617 close;
#P message 124 356 28 196617 open;
#P toggle 31 343 15 0;
#P newex 31 371 54 196617 metro 2;
#P newex 31 407 104 196617 jit.dx.grab 320 240;
#P window setfont “Proportional Serif” 10.;
#P comment 439 267 96 131727370 Show Tracked Region;
#P comment 428 145 110 131727370 Track a Color Range;
#P window setfont “Fixedwidth Serif” 10.;
#P user ubumenu 577 153 140 1441802 0 1 1 0;
#X add 0 = Produce No Sound;
#X add 1 = Play MIDI Notes;
#X add 2 = Play MSP Tones;
#X prefix_set 0 0 0;
#X pattrmode 1;
#P window linecount 2;
#N vpatcher 235 227 784 539;
#P origin -68 -16;
#P window setfont “Proportional Serif” 10.;
#P comment 295 94 28 131727370 Freq.;
#P comment 128 94 28 131727370 Freq.;
#P window setfont “Fixedwidth Serif” 10.;
#P number 258 94 37 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 26 43 241 1441802 unpack 0 0 0 0;
#P number 91 94 37 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Proportional Serif” 10.;
#P comment 112 167 83 131727370 Add a little vibrato;
#P comment 41 22 206 131727370 Use horizontal and vertical location as
frequencies;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 210 164 63 1441802 *~;
#P newex 210 141 50 1441802 *~ 0.02;
#P newex 193 114 38 1441802 line~;
#P newex 193 93 62 1441802 pack 0 50;
#P newex 193 187 27 1441802 +~;
#P newex 193 210 43 1441802 cycle~;
#P newex 263 141 53 1441802 cycle~ 5;
#P newex 193 68 200 1441802 expr (239-($i1+(($i2-$i1)/2)))*7;
#P newex 43 164 63 1441802 *~;
#P newex 43 141 50 1441802 *~ 0.02;
#P newex 26 114 38 1441802 line~;
#P newex 26 93 62 1441802 pack 0 50;
#P newex 26 68 164 1441802 expr ($i1+(($i2-$i1)/2))*5;
#P newex 26 187 27 1441802 +~;
#P newex 26 210 43 1441802 cycle~;
#P newex 96 141 68 1441802 cycle~ 4.5;
#P newex 328 112 26 1441802 b 1;
#P newex 243 244 27 1441802 *~;
#P newex 293 244 27 1441802 *~;
#P message 398 167 32 1441802 stop;
#P message 398 244 14 1441802 0;
#P message 382 244 14 1441802 1;
#P newex 398 192 68 1441802 delay 1000;
#P newex 469 167 62 1441802 delay 201;
#P message 469 192 50 1441802 0. 1000;
#P message 328 167 53 1441802 0.5 1000;
#P newex 328 141 62 1441802 onebang 1;
#P newex 328 217 38 1441802 line~;
#P newex 243 269 60 1441802 dac~;
#N comlet rectangle from jit.findbounds;
#P inlet 26 21 15 0;
#P window setfont “Proportional Serif” 10.;
#P comment 358 107 93 131727370 Turn DSP on/off and fade sound in/out;
#P connect 1 0 34 0;
#P connect 34 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 20 0;
#P connect 20 0 17 0;
#P connect 17 0 16 0;
#P fasten 20 0 21 0 31 136 48 136;
#P connect 21 0 22 0;
#P connect 22 0 17 1;
#P fasten 18 0 33 0 31 89 96 89;
#P connect 15 0 22 1;
#P connect 34 2 18 1;
#P fasten 34 1 23 0 108 64 198 64;
#P connect 23 0 27 0;
#P connect 27 0 28 0;
#P connect 28 0 26 0;
#P connect 26 0 25 0;
#P fasten 28 0 29 0 198 136 215 136;
#P connect 29 0 30 0;
#P connect 30 0 26 1;
#P fasten 16 0 13 0 31 236 248 236;
#P fasten 10 0 2 0 403 265 248 265;
#P fasten 9 0 2 0 387 265 248 265;
#P connect 13 0 2 0;
#P fasten 23 0 35 0 198 89 263 89;
#P fasten 3 0 13 1 333 239 265 239;
#P connect 24 0 30 1;
#P fasten 25 0 12 0 198 231 298 231;
#P connect 12 0 2 1;
#P fasten 3 0 12 1 333 239 315 239;
#P fasten 1 0 14 0 31 39 396 39 396 89 333 89;
#P connect 14 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 3 0;
#P fasten 6 0 3 0 474 213 333 213;
#P fasten 7 0 4 1 474 188 465 188 465 137 385 137;
#P fasten 4 0 9 0 333 162 387 162;
#P fasten 34 3 23 1 262 64 388 64;
#P fasten 4 0 11 0 333 162 403 162;
#P fasten 7 0 8 0 474 188 403 188;
#P connect 11 0 8 0;
#P connect 8 0 10 0;
#P fasten 14 0 7 0 333 133 474 133;
#P connect 7 0 6 0;
#P pop;
#P newobj 640 221 60 1441802 patcher playtones;
#P window linecount 1;
#P newex 577 200 73 1441802 gate 2;
#P newex 640 179 80 1441802 pack 0 0 0 0;
#P window linecount 2;
#N vpatcher 381 48 730 311;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 77 52 112 1441802 unpack 0 0 0 0;
#P window setfont “Proportional Serif” 10.;
#P comment 94 35 148 131727370 Use coordinates to play MIDI notes;
#P comment 158 144 40 131727370 velocity;
#P comment 49 144 28 131727370 pitch;
#P comment 145 109 119 131727370 put in usable velocity range;
#P comment 1 125 72 131727370 look up in scale;
#P comment 1 104 75 131727370 ignore duplicates;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 77 81 170 1441802 expr ($i1+(($i2-$i1)/2))/16;
#P newex 123 123 200 1441802 expr (239-($i1+(($i2-$i1)/2)))/2;
#P newex 77 187 62 1441802 noteout a;
#P newex 77 162 102 1441802 makenote 100 200;
#P number 123 144 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 77 144 35 10 0 0 256 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 77 102 44 1441802 change;
#N vtable 20 40 55 250 222 980020 128;
#T set 0 24 36 43 48 52 55 58 60 63 65 67 70 72 75 77 78 79 81 82 84;
#P newobj 77 123 38 1441802 table;
#N comlet rectangle from jit.findbounds;
#P inlet 77 34 15 0;
#P window setfont “Proportional Serif” 10.;
#P comment 1 83 76 131727370 put in range 0-19;
#P connect 1 0 16 0;
#P connect 16 0 9 0;
#P connect 9 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P fasten 6 1 7 1 174 183 108 183;
#P fasten 16 1 8 0 116 77 128 77;
#P connect 8 0 5 0;
#P connect 5 0 6 1;
#P fasten 16 2 9 1 150 77 242 77;
#P fasten 16 3 8 1 184 73 318 73;
#P pop;
#P newobj 577 221 60 1441802 patcher playnotes;
#P user jit.pwindow 358 255 82 62 0 1 0 0 1 0;
#P window linecount 1;
#P newex 359 233 68 1441802 jit.matrix;
#P newex 422 179 110 1441802 prepend srcdimend;
#P toggle 446 229 15 0;
#P objectname usesrcdim;
#P message 446 247 80 1441802 usesrcdim $1;
#P newex 369 204 122 1441802 prepend srcdimstart;
#P window linecount 3;
#P newex 369 92 116 1441802 jit.findbounds @min 0. 0.9 0. 0. @max 1. 1. 0. 0.;
#B color 5;
#P user jit.pwindow 25 76 322 242 0 1 0 0 1 0;
#P window linecount 1;
#P message 330 -7 83 1441802 saturation $1;
#P flonum 330 -25 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname saturation;
#P message 244 -7 73 1441802 contrast $1;
#P flonum 244 -25 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname contrast;
#P message 158 -7 83 1441802 brightness $1;
#P flonum 158 -25 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname brightness;
#P newex 26 17 68 1441802 jit.brcosa;
#P user panel 574 148 149 108;
#X brgb 255 127 255;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 12.;
#P comment 574 131 184 196620 Use Tracking Info for Sound;
#P user panel 354 92 182 229;
#X brgb 127 255 255;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 153 -32 265 46;
#X brgb 127 255 127;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont “Sans Serif” 9.;
#P comment 153 -47 188 196617 settings for color-management;
#P user panel 574 276 219 192;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P number 576 530 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 574 260 156 196617 Calculation for center of region;
#P connect 79 0 88 0;
#P connect 79 0 83 0;
#P connect 79 0 86 0;
#P fasten 84 0 80 0 674 705 596 705;
#P connect 80 0 82 0;
#P connect 87 0 80 0;
#P fasten 86 0 82 0 747 733 596 733;
#P connect 85 1 83 1;
#P connect 85 0 79 0;
#P fasten 60 0 85 0 581 591 674 591;
#P connect 83 0 84 0;
#P fasten 61 0 83 2 700 619 716 619;
#P connect 82 0 81 0;
#P connect 78 0 8 0;
#P connect 68 0 78 0;
#P connect 77 0 76 0;
#P connect 72 0 70 1;
#P fasten 70 0 68 0 47 619 47 619;
#P fasten 69 0 68 0 210 616 47 616;
#P fasten 73 0 68 0 146 616 47 616;
#P fasten 74 0 68 0 180 616 47 616;
#P fasten 75 0 68 0 134 616 47 616;
#P fasten 76 0 68 0 246 616 47 616;
#P connect 71 0 70 0;
#P connect 16 1 20 0;
#P fasten 16 1 36 0 427 141 560 141 560 271 659 271;
#P fasten 16 1 24 2 427 171 691 171;
#P connect 16 0 17 0;
#P fasten 16 0 35 0 374 162 544 162 544 271 581 271;
#P fasten 16 0 24 0 374 175 645 175;
#P connect 8 0 15 0;
#P fasten 8 0 21 0 31 38 364 38;
#P fasten 8 0 16 0 31 38 374 38;
#P fasten 30 0 8 0 36 440 12 440 12 12 31 12;
#P fasten 14 0 8 0 335 13 31 13;
#P fasten 12 0 8 0 249 13 31 13;
#P fasten 10 0 8 0 163 13 31 13;
#P connect 32 0 31 0;
#P fasten 34 0 30 0 196 393 36 393;
#P fasten 33 0 30 0 129 396 36 396;
#P connect 31 0 30 0;
#P connect 9 0 10 0;
#P connect 11 0 12 0;
#P connect 13 0 14 0;
#P connect 56 0 55 0;
#P connect 55 0 58 0;
#P connect 58 0 54 0;
#P connect 54 0 53 0;
#P fasten 54 1 53 0 384 646 362 646;
#P fasten 18 0 21 0 451 266 442 266 442 229 364 229;
#P fasten 20 0 21 0 427 200 364 200;
#P fasten 17 0 21 0 374 225 364 225;
#P connect 21 0 22 0;
#P connect 54 2 59 0;
#P connect 57 0 55 1;
#P connect 19 0 18 0;
#P connect 63 0 62 0;
#P connect 35 0 37 0;
#P connect 37 0 42 0;
#P connect 42 0 51 0;
#P connect 51 0 50 0;
#P connect 50 0 1 0;
#P connect 1 0 60 0;
#P connect 27 0 25 0;
#P connect 25 0 23 0;
#P fasten 35 1 38 0 609 302 620 302;
#P connect 38 0 41 0;
#P connect 24 0 25 1;
#P connect 25 1 26 0;
#P connect 36 0 39 0;
#P fasten 36 1 40 0 687 302 698 302;
#P fasten 43 0 52 0 758 470 700 470;
#P connect 52 0 66 0;
#P connect 66 0 61 0;
#P fasten 39 0 42 1 659 333 711 333;
#P fasten 41 0 43 0 620 413 758 413;
#P fasten 40 0 41 1 698 328 783 328;
#P window clipboard copycount 89;

#99498
Mar 29, 2007 at 8:46pm

Hey Wesley,
thank you very much for your correction! I will have a try with the new patch on my laptop. On my PC I don’t have any problems, because the CPU is large enought.
I will go on now with my project, because finally I want to catch the mouvements of two colors and together they should create the lines.
Just what I don’t understand is the counter. Because I would have to catch the colors for about one hour and also draw the lines at the same time. So I don’t want to erase the lines. I set up the counter to 100000 so that gives me more time but I don’t know if this is a good idea. What do you think?
Big THANKS,
Johannes

#99499

You must be logged in to reply to this topic.