Filling a rectangular matrix area

Apr 11, 2006 at 1:21pm

Filling a rectangular matrix area

Hello,
I am generating 2 random coordinates (a,b) in a 20 x 15 matrix, and
trying to fill with a random grey color the portion of the matrix
whose coordinates are
x > a and y < b
I don’t know why when i do the comparison I always get a stripe of the
random color in the first column of the matrix. Can you suggest how to
solve this? I think using uzi to fill a list to be crunched by
jit.fill is not a great solution, so if you understand what I am
trying to do, that is really simple, and have a better solution please
give me an advice. Thanks a lot,
Ale

My patch:

max v2;
#N vpatcher 62 43 717 608;
#P origin 0 66;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 355 360 46 9109513 append 0;
#P window linecount 0;
#P message 309 401 69 9109513;
#P window linecount 1;
#P message 120 127 24 9109513 set;
#P number 269 326 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 328 205 27 9109513 < ;
#P button 268 45 15 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 355 135 62 9240586 random 15;
#P window setfont “Sans Serif” 9.;
#P message 269 358 51 9109513 append $1;
#P newex 269 290 41 9109513 select 1;
#P newex 269 254 27 9109513 &;
#P newex 214 203 27 9109513 >;
#P newex 258 85 40 9109513 Uzi 15;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 182 151 62 9240586 random 20;
#P window setfont “Sans Serif” 9.;
#P newex 258 121 40 9109513 Uzi 20;
#P newex 433 301 57 9109513 random 255;
#P newex 269 23 41 9109513 select 1;
#P newex 269 0 47 9109513 random 2;
#P message 165 418 28 9109513 clear;
#P toggle 269 -54 15 0;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 309 531 194 9240586 jit.window Display 450 60 20 15;
#P newex 309 431 92 9240586 jit.fill foo 0;
#B color 5;
#P window setfont “Sans Serif” 9.;
#P newex 309 466 116 9109513 jit.matrix foo 1 char 20 15;
#P newex 269 -28 50 9109513 metro 500;
#P fasten 17 0 20 0 273 59 125 59;
#P fasten 17 0 5 0 273 60 170 60;
#P fasten 17 0 10 0 273 77 187 77;
#P fasten 9 2 12 0 293 180 219 180;
#P fasten 10 0 12 1 187 178 236 178;
#P connect 17 0 11 0;
#P connect 11 0 9 0;
#P connect 7 0 17 0;
#P connect 4 0 0 0;
#P connect 0 0 6 0;
#P connect 6 0 7 0;
#P fasten 12 0 13 0 219 238 274 238;
#P connect 13 0 14 0;
#P fasten 8 0 19 0 438 323 274 323;
#P connect 14 0 19 0;
#P connect 19 0 15 0;
#P fasten 18 0 13 1 333 242 291 242;
#P fasten 11 1 21 0 278 115 314 115;
#P connect 22 0 21 0;
#P connect 15 0 21 0;
#P fasten 20 0 21 0 125 400 314 400;
#P connect 21 0 2 0;
#P connect 2 0 1 0;
#P fasten 5 0 1 0 170 465 314 465;
#P connect 1 0 3 0;
#P fasten 11 2 18 0 293 115 333 115;
#P fasten 16 0 18 1 360 179 350 179;
#P fasten 17 0 16 0 273 78 360 78;
#P fasten 14 1 22 0 305 323 360 323;
#P fasten 17 0 8 0 273 60 438 60;
#P pop;

#25358
Apr 11, 2006 at 3:01pm

For this sort of task, I recommend using the jit.expr object or the
exprfill message to jit.matrix. See the jit.expr help file and examples
for more info.


Andrew B.

#74599
Apr 11, 2006 at 3:04pm

Hi,
If you’re trying to fill a rectangular area of a matrix, you can use
jit.lcd to do it. If you’re just wanting to do it on the final
output, you can use opengl drawing commands to do it.

best,
wes

#74600
Apr 11, 2006 at 6:40pm

thanks guys, I was stuck on that doing complicated stuff I knew there
would have been an easier way for such a simple task.
ale

#74601

You must be logged in to reply to this topic.