LCD linesegment weirdness (max 4.6.3)

Jul 2, 2008 at 12:26pm

LCD linesegment weirdness (max 4.6.3)

i really don’t understand why this is behaving the way it is.
what’s so difficult about drawing a vertical line?

when sprites are not enabled it’s no problem to make a vertical line, but i need it to be a sprite because i have to draw and hide 4 different ones independently from eachother on the same LCD.

max v2;
#N vpatcher 508 55 1128 596;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 117 101 100 196617 and here the line is totally invisible!!;
#P comment 250 97 100 196617 here it becomes a dashed line (huh?);
#P window linecount 1;
#P message 420 242 79 196617 enablesprites 1;
#P message 272 154 67 196617 10 10 1 150;
#P message 253 131 73 196617 10 10 40 150;
#P newex 392 217 48 196617 loadbang;
#P user lcd 219 293 200 200 1 1 0 0 1;
#P message 155 132 73 196617 10 10 10 150;
#P message 412 112 79 196617 10 10 150 150;
#P toggle 42 76 28 0;
#P message 340 240 46 196617 0 0 255;
#P message 395 240 14 196617 4;
#P message 431 135 73 196617 10 10 150 10;
#N vpatcher 20 74 955 742;
#N comlet positie;
#P inlet 528 53 15 0;
#P window setfont “Sans Serif” 9.;
#P newex 361 295 36 196617 zl reg;
#P newex 143 464 110 196617 sprintf hidesprite test;
#P newex 278 122 236 196617 t b b b b b b;
#P newex 483 194 101 196617 sprintf recordsprite;
#P newex 143 94 281 196617 sel 0 1;
#P toggle 143 66 15 0;
#N comlet pensize;
#P inlet 669 45 15 0;
#P outlet 460 577 15 0;
#N comlet draw/hide;
#P inlet 143 40 15 0;
#P newex 478 334 58 196617 unpack i i i;
#P newex 478 311 36 196617 zl reg;
#P newex 360 322 64 196617 unpack i i i i;
#P newex 332 392 209 196617 sprintf linesegment %f %f %f %f %f %f %f;
#P newex 274 464 133 196617 sprintf drawsprite test 0 0;
#P newex 297 427 115 196617 sprintf closesprite test;
#P newex 440 251 107 196617 sprintf pensize %i %i;
#N comlet kleur;
#P inlet 583 46 15 0;
#P connect 8 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 15 0;
#P connect 14 0 3 0;
#P connect 12 1 14 0;
#P connect 14 1 2 0;
#P connect 5 0 4 0;
#P connect 16 0 5 0;
#P connect 14 2 16 0;
#P connect 5 1 4 1;
#P connect 17 0 16 1;
#P connect 5 2 4 2;
#P connect 5 3 4 3;
#P connect 14 4 1 0;
#P connect 2 0 9 0;
#P connect 3 0 9 0;
#P connect 15 0 9 0;
#P connect 13 0 9 0;
#P connect 1 0 9 0;
#P connect 4 0 9 0;
#P connect 7 0 4 4;
#P connect 14 3 6 0;
#P connect 6 0 7 0;
#P connect 14 5 13 0;
#P connect 7 1 4 5;
#P connect 0 0 6 1;
#P connect 7 2 4 6;
#P connect 10 0 1 1;
#P pop;
#P newobj 219 266 185 196617 p stripe;
#P comment 417 95 100 196617 this works fine;
#P comment 25 49 118 196617 press to draw/hide line;
#P connect 6 0 2 0;
#P connect 2 0 9 0;
#P fasten 13 0 9 0 425 284 224 284;
#P connect 7 0 2 1;
#P connect 3 0 2 1;
#P connect 11 0 2 1;
#P connect 12 0 2 1;
#P connect 8 0 2 1;
#P connect 5 0 2 2;
#P connect 10 0 5 0;
#P connect 4 0 2 3;
#P connect 10 0 4 0;
#P connect 10 0 13 0;
#P pop;

#38709
Jul 2, 2008 at 2:17pm

linesegment doesn’t understand seven arguments, the color has to be
set separately.
your use of sprintf is *interesting* but completly misses the point.
messageboxes with argments work prefectly fine for this kind message
sequence, but you could also use textfile with text or a coll to make
longer sequences of sprites.
you don’t have to rerecord the same sprite over and over. it stays in
memory, that’s kind of the idea behind sprites. just give them
different names and draw them hen needed. otherwise you can just do a
plain drawing sequence using new values for linesegment.

hth

/*j

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 529 289 138 196617 frgb 255 127 0 , pensize 3 3;
#P hidden newex 587 570 53 196617 autopattr;
#X prestore pt1.x 1 0 20;
#X prestore pt1.y 1 0 20;
#X prestore pt2.x 1 0 183;
#X prestore pt2.y 1 0 20;
#P objectname u200000004;
#P number 479 192 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname pt1.x;
#P number 518 192 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname pt1.y;
#P number 565 192 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname pt2.x;
#P number 604 192 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname pt2.y;
#P newex 468 262 135 196617 t l b clear;
#P newex 468 231 147 196617 pak linesegment 10 10 10 150;
#P message 251 139 67 196617 10 10 1 150;
#P message 242 121 73 196617 10 10 40 150;
#P user lcd 25 388 200 200 1 1 0 0 1;
#P message 232 103 73 196617 10 10 10 150;
#P message 261 156 79 196617 10 10 150 150;
#P toggle 25 76 28 0;
#P message 271 174 73 196617 10 10 150 10;
#P comment 56 83 118 196617 press to draw/hide line;
#P window linecount 4;
#P message 232 271 174 196617 enablesprites 1 , recordsprite , frgb
$5 $6 $7 , pensize $8 $8 , linesegment $1 $2 $3 $4 ,
closesprite test;
#P window linecount 1;
#P message 25 271 76 196617 hidesprite test;
#P newex 232 235 139 196617 pak 10 10 10 150 0 0 255 4;
#P newex 25 235 41 196617 sel 0 1;
#P toggle 25 207 15 0;
#P message 124 271 99 196617 drawsprite test 0 0;
#P comment 468 344 123 196617 normal drawing sequence;
#P connect 16 1 22 0;
#P fasten 16 2 12 0 597 333 30 333;
#P connect 15 0 16 0;
#P fasten 16 0 12 0 473 333 30 333;
#P fasten 22 0 12 0 534 334 30 334;
#P connect 17 0 15 4;
#P connect 18 0 15 3;
#P connect 19 0 15 2;
#P connect 20 0 15 1;
#P connect 10 0 4 0;
#P connect 8 0 4 0;
#P connect 13 0 4 0;
#P connect 14 0 4 0;
#P connect 11 0 4 0;
#P connect 6 0 12 0;
#P connect 1 0 12 0;
#P connect 5 0 12 0;
#P connect 9 0 2 0;
#P connect 4 0 6 0;
#P connect 3 1 1 0;
#P connect 3 0 5 0;
#P connect 2 0 3 0;
#P window clipboard copycount 23;

#135200
Jul 2, 2008 at 3:24pm

Quote: jasch wrote on Wed, 02 July 2008 16:17
—————————————————-
> linesegment doesn’t understand seven arguments, the color has to be
> set separately.

in my experience it works fine with 7 arguments.

> your use of sprintf is *interesting* but completly misses the point.
> messageboxes with argments work prefectly fine for this kind message
> sequence, but you could also use textfile with text or a coll to make
> longer sequences of sprites.

yes i know, this patch was derived from another one, just kept the sprintf’s out of laziness.

> you don’t have to rerecord the same sprite over and over. it stays in
> memory, that’s kind of the idea behind sprites. just give them
> different names and draw them hen needed.

i thought i had to do it this was, because i need 4 lines that each have 3 appearances (horizontal, vertical, diagonal)
as far as i know, there’s no way to rotate and scale sprites. all you can do is move them with an x,y coordinate.
i suppose i could also make 12 sprites and just draw/hide them.

> otherwise you can just do a
> plain drawing sequence using new values for linesegment.
that doesn’t work for me because i need to draw/hide 4 different lines with each a different color indepently from eachother. frgb changes the color for all.

weirdly enough, it works now.
but i still don’t see what’s so different in the end.

max v2;
#N vpatcher 203 44 1018 702;
#P window setfont “Sans Serif” 9.;
#P number 650 170 35 9 1 10 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 452 114 58 196617 unpack i i i;
#P user swatch 448 60 128 32;
#P number 528 170 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 480 168 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 438 167 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 587 570 53 196617 autopattr;
#P objectname u345000007;
#P message 251 139 67 196617 10 10 1 150;
#P message 242 121 73 196617 10 10 40 150;
#P user lcd 25 388 200 200 1 1 0 0 1;
#P message 232 103 73 196617 10 10 10 150;
#P message 261 156 79 196617 10 10 150 150;
#P toggle 25 76 28 0;
#P message 271 174 73 196617 10 10 150 10;
#P comment 56 83 118 196617 press to draw/hide line;
#P window linecount 2;
#P message 232 271 246 196617 enablesprites 1 , recordsprite , pensize $8 $8 , linesegment $1 $2 $3 $4 $5 $6 $7 , closesprite test;
#P window linecount 1;
#P message 25 271 76 196617 hidesprite test;
#P newex 232 235 139 196617 pak 10 10 10 150 0 0 255 4;
#P newex 25 235 41 196617 sel 0 1;
#P toggle 25 207 15 0;
#P message 124 271 99 196617 drawsprite test 0 0;
#P comment 658 145 100 196617 pensize;
#P connect 9 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 5 0;
#P connect 5 0 12 0;
#P connect 1 0 12 0;
#P connect 6 0 12 0;
#P connect 3 1 1 0;
#P connect 11 0 4 0;
#P connect 14 0 4 0;
#P connect 13 0 4 0;
#P connect 8 0 4 0;
#P connect 10 0 4 0;
#P connect 4 0 6 0;
#P connect 16 0 4 4;
#P connect 17 0 4 5;
#P connect 18 0 4 6;
#P connect 21 0 4 7;
#P connect 20 0 16 0;
#P connect 19 0 20 0;
#P connect 20 1 17 0;
#P connect 20 2 18 0;
#P pop;

#135201
Jul 2, 2008 at 3:33pm

ok, so i changed all the unneccesary sprintf’s into plain messages and now it works.
i would just like to know why…

compare this

max v2;
#N vpatcher 33 49 653 590;
#P user lcd 304 313 128 128 1 1 0 0 1;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 420 242 79 196617 enablesprites 1;
#P message 272 154 67 196617 10 10 1 150;
#P message 253 131 73 196617 10 10 40 150;
#P newex 392 217 48 196617 loadbang;
#P message 155 132 73 196617 10 10 10 150;
#P message 412 112 79 196617 10 10 150 150;
#P toggle 42 76 28 0;
#P message 340 240 46 196617 0 0 255;
#P message 395 240 14 196617 4;
#P message 431 135 73 196617 10 10 150 10;
#N vpatcher 20 74 788 746;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 156 475 76 196617 hidesprite test;
#P message 282 460 99 196617 drawsprite test 0 0;
#P message 301 433 81 196617 closesprite test;
#P window linecount 0;
#P message 456 227 73 196617 pensize $1 $1;
#N comlet positie;
#P inlet 528 53 15 0;
#P newex 361 295 36 196617 zl reg;
#P newex 278 122 210 196617 t b b b b b recordsprite;
#P newex 143 94 281 196617 sel 0 1;
#P toggle 143 66 15 0;
#N comlet pensize;
#P inlet 669 45 15 0;
#P outlet 460 577 15 0;
#N comlet draw/hide;
#P inlet 143 40 15 0;
#P newex 478 334 58 196617 unpack i i i;
#P newex 478 311 36 196617 zl reg;
#P newex 360 322 64 196617 unpack i i i i;
#P newex 332 392 209 196617 sprintf linesegment %f %f %f %f %f %f %f;
#N comlet kleur;
#P inlet 583 46 15 0;
#P connect 5 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 16 0;
#P connect 9 1 10 0;
#P connect 10 0 15 0;
#P connect 10 1 14 0;
#P connect 2 0 1 0;
#P connect 11 0 2 0;
#P connect 10 2 11 0;
#P connect 2 1 1 1;
#P connect 12 0 11 1;
#P connect 2 2 1 2;
#P connect 2 3 1 3;
#P connect 10 4 13 0;
#P connect 7 0 13 0;
#P connect 1 0 6 0;
#P connect 13 0 6 0;
#P connect 14 0 6 0;
#P connect 15 0 6 0;
#P connect 16 0 6 0;
#P connect 10 5 6 0;
#P connect 4 0 1 4;
#P connect 10 3 3 0;
#P connect 3 0 4 0;
#P connect 4 1 1 5;
#P connect 0 0 3 1;
#P connect 4 2 1 6;
#P pop;
#P newobj 219 266 185 196617 p stripe;
#P comment 25 49 118 196617 press to draw/hide line;
#P connect 5 0 1 0;
#P connect 6 0 1 1;
#P connect 2 0 1 1;
#P connect 9 0 1 1;
#P connect 10 0 1 1;
#P connect 7 0 1 1;
#P connect 1 0 12 0;
#P connect 11 0 12 0;
#P connect 4 0 1 2;
#P connect 8 0 4 0;
#P connect 3 0 1 3;
#P connect 8 0 3 0;
#P connect 8 0 11 0;
#P pop;

to this

max v2;
#N vpatcher 508 55 1128 596;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 117 101 100 196617 and here the line is totally invisible!!;
#P comment 250 97 100 196617 here it becomes a dashed line (huh?);
#P window linecount 1;
#P message 420 242 79 196617 enablesprites 1;
#P message 272 154 67 196617 10 10 1 150;
#P message 253 131 73 196617 10 10 40 150;
#P newex 392 217 48 196617 loadbang;
#P user lcd 219 293 200 200 1 1 0 0 1;
#P message 155 132 73 196617 10 10 10 150;
#P message 412 112 79 196617 10 10 150 150;
#P toggle 42 76 28 0;
#P message 340 240 46 196617 0 0 255;
#P message 395 240 14 196617 4;
#P message 431 135 73 196617 10 10 150 10;
#N vpatcher 20 74 955 742;
#N comlet positie;
#P inlet 528 53 15 0;
#P window setfont “Sans Serif” 9.;
#P newex 361 295 36 196617 zl reg;
#P newex 143 464 110 196617 sprintf hidesprite test;
#P newex 278 122 236 196617 t b b b b b b;
#P newex 483 194 101 196617 sprintf recordsprite;
#P newex 143 94 281 196617 sel 0 1;
#P toggle 143 66 15 0;
#N comlet pensize;
#P inlet 669 45 15 0;
#P outlet 460 577 15 0;
#N comlet draw/hide;
#P inlet 143 40 15 0;
#P newex 478 334 58 196617 unpack i i i;
#P newex 478 311 36 196617 zl reg;
#P newex 360 322 64 196617 unpack i i i i;
#P newex 332 392 209 196617 sprintf linesegment %f %f %f %f %f %f %f;
#P newex 274 464 133 196617 sprintf drawsprite test 0 0;
#P newex 297 427 115 196617 sprintf closesprite test;
#P newex 440 251 107 196617 sprintf pensize %i %i;
#N comlet kleur;
#P inlet 583 46 15 0;
#P connect 8 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 15 0;
#P connect 14 0 3 0;
#P connect 12 1 14 0;
#P connect 14 1 2 0;
#P connect 5 0 4 0;
#P connect 16 0 5 0;
#P connect 14 2 16 0;
#P connect 5 1 4 1;
#P connect 17 0 16 1;
#P connect 5 2 4 2;
#P connect 5 3 4 3;
#P connect 14 4 1 0;
#P connect 2 0 9 0;
#P connect 3 0 9 0;
#P connect 15 0 9 0;
#P connect 13 0 9 0;
#P connect 1 0 9 0;
#P connect 4 0 9 0;
#P connect 7 0 4 4;
#P connect 14 3 6 0;
#P connect 6 0 7 0;
#P connect 14 5 13 0;
#P connect 7 1 4 5;
#P connect 0 0 6 1;
#P connect 7 2 4 6;
#P connect 10 0 1 1;
#P pop;
#P newobj 219 266 185 196617 p stripe;
#P comment 417 95 100 196617 this works fine;
#P comment 25 49 118 196617 press to draw/hide line;
#P connect 6 0 2 0;
#P connect 2 0 9 0;
#P fasten 13 0 9 0 425 284 224 284;
#P connect 7 0 2 1;
#P connect 3 0 2 1;
#P connect 11 0 2 1;
#P connect 12 0 2 1;
#P connect 8 0 2 1;
#P connect 5 0 2 2;
#P connect 10 0 5 0;
#P connect 4 0 2 3;
#P connect 10 0 4 0;
#P connect 10 0 13 0;
#P pop;

#135202

You must be logged in to reply to this topic.