Forums > Jitter

setcell and jit.pwindow as GUI – simple mapping problem

April 17, 2008 | 5:35 pm

Hello,

I have this patch below, which allows to interpolate a little matrix to a bigger one.
It uses [jit.pwindow] as GUI to "setcell" for the little matrix.

If I change the dimensions of this matrix, then the mouse pointer in the pwindow doesn’t "accord" anymore with coords cells in [jit.pwindow].

I know it’s a maths mapping problem, and it comes quite often,
but I don’t know how to approach it.

Does anyone get an example patch somewhere which could help me?

thank you very much.

max v2;
#N vpatcher 189 44 1007 830;
#P origin 44 -75;
#P window setfont "Sans Serif" 24.;
#P window linecount 1;
#P comment 44 415 141 196632 4 change->;
#P comment 429 23 141 196632 < -4 change;
#P comment 331 414 141 196632 < -3 change;
#P comment 523 220 141 196632 < -2 change;
#P comment 313 99 172 196632 < -1 draw here;
#P window setfont "Sans Serif" 9.;
#P newex 699 92 61 196617 t 8 b 200 1;
#P newex 699 69 48 196617 loadbang;
#P comment 241 666 76 196617 out matrix;
#P comment 239 600 76 196617 control matrix;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 126 55 76 1441802 r ctlmatrix;
#B color 5;
#P window setfont "Sans Serif" 9.;
#P number 468 398 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 206 35 15 0;
#P message 206 56 52 196617 interp $1;
#P newex 468 376 87 196617 scale 2 10 50 10;
#P comment 405 682 113 196617 matrice d’interpolation;
#P number 456 346 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 456 322 27 196617 + 2;
#P user radiogroup 456 176 18 128;
#X size 9;
#X offset 14;
#X inactive 0;
#X itemtype 0;
#X flagmode 0;
#X set 8;
#X done;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 244 639 76 1441802 s ctlmatrix;
#B color 5;
#P window setfont "Sans Serif" 9.;
#P message 307 56 70 196617 size 100 100;
#P message 259 56 47 196617 getstate;
#P user jit.pwindow 205 80 102 102 0 1 0 0 1 0;
#P message 456 580 56 196617 dim $1 $1;
#P newex 254 458 67 196617 unpack 0 0 0;
#P newex 314 167 37 196617 zl rev;
#P comment 327 196 24 196617 x , y;
#P message 333 250 37 196617 $1 $1;
#P newex 228 221 51 196617 zl ecils 1;
#P newex 314 148 65 196617 route mouse;
#P newex 226 273 82 196617 vexpr $i1 / $i2;
#P window linecount 2;
#P user com 230 318 95 196617 17;
#K set 0 8481 8313 11296 30752 8225 8480 3426 25955 24949 29541 8303 26144 23418 27680 29285 30301 8192;
#K end;
#P window linecount 1;
#P newex 226 294 108 196617 unpack 0 0;
#P comment 204 198 33 196617 clic;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 118 269 46 1441802 s joue;
#B color 5;
#P outlet 226 710 15 0;
#P window setfont "Sans Serif" 9.;
#P comment 152 373 56 196617 • clear all;
#P comment 163 407 42 196617 • clear;
#P toggle 163 422 15 0;
#P newex 305 576 47 196617 gate 1 1;
#P comment 254 352 43 196617 • depth;
#P comment 454 160 53 196617 • how big;
#P comment 479 292 24 196617 min;
#P comment 475 178 29 196617 max;
#P newex 226 679 176 196617 jit.matrix 1 char 100 100 @interp 1;
#P newex 254 367 48 196617 loadbang;
#P newex 226 550 126 196617 t b l clear;
#P message 254 387 65 196617 saturation 0;
#P user swatch 254 406 48 46;
#P newex 237 480 27 196617 i;
#P message 152 387 71 196617 setall 0 , bang;
#P comment 265 482 34 196617 value;
#P message 251 526 102 196617 setcell $2 $3 val $1;
#P comment 331 489 69 196617 x , y positions;
#P user com 115 290 92 196617 10;
#K set 0 12832 29545 27753 25445 24877 26220 24942 26414 28769 29696;
#K end;
#P newex 269 242 32 196617 sel 1;
#P newex 226 614 117 196617 jit.matrix 1 char 10 10;
#P newex 228 195 98 196617 zl ecils 2;
#P comment 345 616 137 196617 dims : min 2×2 , max 10×10;
#P newex 369 167 58 196617 print state;
#P newex 251 505 157 196617 pack 0 0 0;
#P user panel 446 148 74 169;
#X brgb 255 255 255;
#X frgb 156 252 144;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 226 35 184 196617 • show control matrix or out matrix ?;
#P user panel 200 31 226 23;
#X brgb 255 255 255;
#X frgb 156 252 144;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 247 346 75 110;
#X brgb 255 255 255;
#X frgb 156 252 144;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 145 364 86 85;
#X brgb 255 255 255;
#X frgb 156 252 144;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P fasten 10 0 31 0 274 261 123 261;
#P hidden connect 59 3 27 0;
#P connect 53 0 52 0;
#P fasten 44 0 43 0 264 75 211 75;
#P fasten 45 0 43 0 312 75 211 75;
#P connect 52 0 43 0;
#P fasten 55 0 43 0 131 75 211 75;
#P fasten 8 1 35 0 321 268 231 268;
#P connect 35 0 33 0;
#P fasten 13 0 19 0 256 546 231 546;
#P fasten 15 0 9 0 157 589 231 589;
#P connect 19 0 9 0;
#P fasten 19 1 9 0 289 571 231 571;
#P fasten 42 0 9 0 461 597 231 597;
#P fasten 26 0 9 0 310 597 231 597;
#P connect 9 0 21 0;
#P connect 21 0 30 0;
#P fasten 40 0 8 0 319 189 233 189;
#P connect 8 0 37 0;
#P fasten 10 0 16 0 183 329 243 403 208 453;
#P fasten 9 0 46 0 231 636 249 636;
#P fasten 16 0 5 0 242 502 256 502;
#P connect 5 0 13 0;
#P connect 20 0 18 0;
#P hidden connect 59 1 18 0;
#P connect 18 0 17 0;
#P hidden connect 59 2 17 0;
#P connect 17 0 41 0;
#P connect 41 0 16 1;
#P connect 37 1 10 0;
#P connect 38 0 35 1;
#P fasten 27 0 26 0 168 574 310 574;
#P fasten 43 1 36 0 301 184 310 184 310 141 319 141;
#P connect 36 0 40 0;
#P connect 33 1 5 1;
#P fasten 54 0 38 0 439 440 439 224;
#P connect 19 2 26 1;
#P connect 36 1 6 0;
#P fasten 33 0 5 2 231 316 402 316;
#P hidden connect 59 0 47 0;
#P connect 47 0 48 0;
#P connect 48 0 49 0;
#P connect 49 0 42 0;
#P connect 49 0 51 0;
#P connect 51 0 54 0;
#P connect 58 0 59 0;
#P pop;


Viewing 1 post (of 1 total)