Forums > MaxMSP

Draw Above Sprites in LCD

March 10, 2008 | 9:09 pm

I’m drawing linesegments to reconstruct the waveform contained in a buffer.

Then I’d like to add, at some points, a background symbolising a selection.

I’ve done that using sprite, but the sprite is above the waveform, which means that I can’t see what’s going on in the selection…

The question is : Is there a way to tell [LCD] to draw above the sprite or to draw sprites in the background ?

I’m now using framerect and not paintrect, but it’s not visually as interesting.

Maybe I could make a frame with all the linesegments, but it seems tricky…


March 10, 2008 | 11:11 pm

On 10.03.2008, at 22:09, Bertrand Fraysse wrote:

> The question is : Is there a way to tell [LCD] to draw above the
> sprite or to draw sprites in the background ?

try the frontsprite and backsprite messages
ex [..., closesprite background-foo, drawsprite background-foo 0 0,
backsprite background-foo]
hope that helps.

cheers
piet


March 10, 2008 | 11:37 pm

The problem is that the waveform isn’t a sprite, but is drawn by a basic combination of [linesegment $1 $2 $3 $4 $5]

Here is a simplified version of the patch

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 241 373 50 9109513 3;
#P message 445 467 50 9109513 16;
#P message 444 372 50 9109513 35;
#P flonum 295 475 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 369 372 50 9109513 100;
#P message 294 372 50 9109513 50;
#N vpatcher 414 28 1130 714;
#P window setfont "Sans Serif" 9.;
#P message 85 186 54 9109513 penmode 5;
#P message 209 186 54 9109513 penmode 0;
#P window linecount 1;
#P newex 85 99 61 9109513 r redraw;
#P window linecount 0;
#P newex 85 626 50 9109513 s $0_LCD;
#P newex 405 107 55 9109513 unpack;
#P newex 405 87 55 9109513 r $0_size;
#P newex 405 131 29 9109513 t b i;
#P newex 450 223 27 9109513 / 2.;
#P newex 296 359 138 9109513 peek~ $0_un;
#P message 189 560 139 9109513 linesegment $1 $2 $3 $4 $5;
#P newex 296 391 89 9109513 * 25.;
#P newex 210 519 186 9109513 pack i i i i 69;
#P newex 313 48 33 9109513 * 44.1;
#P newex 147 217 42 9109513 Uzi $2;
#P newex 313 243 38 9109513 / 500.;
#P newex 296 327 27 9109513 * 0.;
#P newex 210 295 96 9109513 t i i;
#P newex 85 163 197 9109513 t b b b b;
#P message 271 186 28 9109513 clear;
#P newex 296 457 32 9109513 + 25.;
#P newex 313 28 76 9109513 r $1_zoomlength;
#B color 6;
#P newex 342 457 118 9109513 expr $f2 – $f1;
#N comlet color;
#P inlet 544 103 15 0;
#P newex 544 131 27 9109513 t b i;
#P newex 505 298 33 9109513 * 1.;
#N comlet vertical zoom;
#P inlet 482 103 15 0;
#P newex 482 131 56 9109513 t b b f;
#P newex 210 268 27 9109513 – 1;
#P connect 25 0 10 0;
#P fasten 4 0 10 0 549 159 90 159;
#P lcolor 15;
#P fasten 1 0 10 0 487 159 90 159;
#P lcolor 15;
#P connect 10 0 27 0;
#P fasten 26 0 24 0 214 211 90 211;
#P connect 27 0 24 0;
#P fasten 18 0 24 0 194 598 90 598;
#P fasten 9 0 24 0 276 213 90 213;
#P connect 10 1 14 0;
#P fasten 21 1 14 1 429 209 184 209;
#P connect 16 0 18 0;
#P connect 10 2 26 0;
#P connect 14 2 0 0;
#P connect 0 0 11 0;
#P connect 11 0 16 0;
#P lcolor 9;
#P connect 8 0 16 1;
#P fasten 10 3 9 0 276 181 276 181;
#P connect 11 1 12 0;
#P connect 12 0 19 0;
#P connect 19 0 17 0;
#P connect 17 0 8 0;
#P connect 11 0 16 2;
#P lcolor 9;
#P connect 7 0 15 0;
#P connect 21 0 13 0;
#P connect 15 0 13 0;
#P connect 13 0 12 1;
#P fasten 20 0 8 1 455 432 323 432;
#P lcolor 7;
#P fasten 21 1 13 1 429 223 346 223;
#P connect 17 0 6 0;
#P connect 6 0 16 3;
#P fasten 3 0 17 1 510 385 380 385;
#P fasten 4 1 16 4 566 495 391 495;
#P connect 22 0 23 0;
#P connect 23 0 21 0;
#P connect 23 1 20 0;
#P connect 20 0 6 1;
#P lcolor 7;
#P connect 2 0 1 0;
#P connect 20 0 3 0;
#P connect 1 1 3 0;
#P connect 1 2 3 1;
#P connect 5 0 4 0;
#P pop;
#P newobj 295 502 160 9109513 p draw;
#P number 369 408 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 294 408 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 172 215 832 675;
#P window setfont "Sans Serif" 9.;
#P newex 196 59 27 9109513 t b i;
#P newex 196 162 27 9109513 +;
#P newex 276 216 50 9109513 – 2;
#P inlet 356 22 15 0;
#P window linecount 1;
#P message 36 336 423 9109513 recordsprite , paintrect $1 $2 $3 $4 $5 , closesprite sel , drawsprite sel 0 0 , backsprite sel;
#P newex 36 372 50 9109513 s $0_LCD;
#P window linecount 0;
#P newex 243 59 43 9109513 unpack;
#P newex 243 39 43 9109513 r $0_size;
#N comlet (int) Selection Lenght;
#P inlet 196 22 15 0;
#N comlet (int) Selection Start;
#P inlet 36 22 15 0;
#P newex 36 301 330 9109513 pak i 2 i 51 i;
#P connect 1 0 0 0;
#P connect 0 0 6 0;
#P connect 6 0 5 0;
#P connect 2 0 10 0;
#P connect 10 0 9 0;
#P connect 9 0 0 2;
#P connect 10 1 9 1;
#P lcolor 9;
#P connect 3 0 4 0;
#P connect 4 1 8 0;
#P connect 8 0 0 3;
#P connect 7 0 0 4;
#P pop;
#P newobj 294 435 160 9109513 p drawselection;
#P message 165 372 28 9109513 2000;
#P flonum 165 390 76 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 165 406 76 9109513 s $1_zoomlength;
#B color 6;
#P message 56 440 41 9109513 replace;
#P newex 56 458 90 9109513 buffer~ $0_un 2000;
#P message 117 388 47 9109513 500 150;
#P newex 117 406 47 9109513 s $0_size;
#P newex 77 328 50 9109513 loadbang;
#P newex 56 408 60 9109513 s redraw;
#P toggle 56 369 15 0;
#P newex 56 388 60 9109513 metro 10;
#P newex 49 54 50 9109513 r $0_LCD;
#P user lcd 49 115 500 150 1 1 1 0 1;
#P comment 331 476 32 9109513 Zoom;
#P connect 2 0 1 0;
#P connect 8 0 7 0;
#P connect 3 0 5 0;
#P connect 4 0 3 0;
#P connect 10 0 9 0;
#P connect 12 0 11 0;
#P connect 13 0 12 0;
#P connect 15 0 14 0;
#P connect 16 0 14 1;
#P connect 18 0 15 0;
#P connect 19 0 16 0;
#P connect 20 0 17 0;
#P connect 21 0 14 2;
#P connect 22 0 17 1;
#P connect 23 0 20 0;
#P connect 6 0 22 0;
#P connect 6 0 21 0;
#P connect 6 0 19 0;
#P connect 6 0 18 0;
#P connect 6 0 23 0;
#P connect 6 0 13 0;
#P connect 6 0 8 0;
#P connect 6 0 4 0;
#P window clipboard copycount 24;

The idea would be to change the content of [p draw] to turn it into a sprite. This seems pretty impossible… I don’t know.

If you have any other idea to put the red selection behind the orange waveform, don’t hesitate.


March 10, 2008 | 11:52 pm

Sprites can be transparent. Try this:
recordsprite, penmode 32, oprgb 128 128 128, paintrect $1 $2 $3 $4 $5, closesprite sel, drawsprite sel 0 0, backsprite sel

_
johan


March 10, 2008 | 11:58 pm

Quote: jvkr wrote on Mon, 10 March 2008 17:52
—————————————————-
> Sprites can be transparent. Try this:
> recordsprite, penmode 32, oprgb 128 128 128, paintrect $1 $2 $3 $4 $5, closesprite sel, drawsprite sel 0 0, backsprite sel
>
> _
> johan
—————————————————-

Amazing, thank you very much Johan. This is… Perfect !


Viewing 5 posts - 1 through 5 (of 5 total)