## keep movie under mask (math problem)

Aug 28, 2006 at 5:08pm

# keep movie under mask (math problem)

I’m trying to move a picture with jit.rota using the offset arguments. This picture is composed with a circular zone, then passing thru a circular mask. How can I keep the playing picture inside the surface of the mask. I think there should be a way to do this mathematicaly, but the problem is that my math skill sucks (furthermore, I’m quite new to Jitter so maybe I went the wrong way). Any help would be greatly appreciated.

As I realise my explanations are perfectly unclear, here’s a demo patch using countdown.mov as an example.

Best,

Julien.

max v2;
#N vpatcher 205 76 1310 826;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 928 97 100 196617 not ok;
#P comment 928 88 100 196617 ok;
#P comment 928 79 100 196617 this is not ok;
#P comment 928 68 100 196617 this is ok;
#N vpreset 5;
#X append 1 2 1 107 33 flonum float 0. ; 5 35 17 toggle int 1 ; 11 178 417 number int 160 ; 12 178 493 number int 120 ; 17 287 417 toggle int 1 ; 18 239 417 number int;
#X append 1 2 0 ; 19 239 493 number int 0 ; 20 118 417 flonum float 3. ; 21 118 482 flonum float 3. ; 22 51 455 flonum float 3. ;;
#X append 2 2 1 107 33 flonum float 0. ; 5 35 17 toggle int 1 ; 11 178 417 number int 160 ; 12 178 493 number int 120 ; 17 287 417 toggle int 1 ; 18 239 417 number int;
#X append 2 2 0 ; 19 239 493 number int 0 ; 20 118 417 flonum float 1. ; 21 118 482 flonum float 1. ; 22 51 455 flonum float 1. ;;
#X append 3 2 1 107 33 flonum float 0. ; 5 35 17 toggle int 1 ; 11 178 417 number int 160 ; 12 178 493 number int 120 ; 17 287 417 toggle int 1 ; 18 239 417 number int;
#X append 3 2 0 ; 19 239 493 number int 0 ; 20 118 417 flonum float 0.8 ; 21 118 482 flonum float 0.8 ; 22 51 455 flonum float 0.8 ;;
#X append 4 2 1 107 33 flonum float 0. ; 5 35 17 toggle int 1 ; 11 178 417 number int 160 ; 12 178 493 number int 120 ; 17 287 417 toggle int 1 ; 18 239 417 number int;
#X append 4 2 68 ; 19 239 493 number int 0 ; 20 118 417 flonum float 2. ; 21 118 482 flonum float 2. ; 22 51 455 flonum float 2. ;;
#X append 5 2 1 107 33 flonum float 0. ; 5 35 17 toggle int 1 ; 11 178 417 number int 160 ; 12 178 493 number int 120 ; 17 287 417 toggle int 1 ; 18 239 417 number int;
#X append 5 2 68 ; 19 239 493 number int 134 ; 20 118 417 flonum float 2. ; 21 118 482 flonum float 2. ; 22 51 455 flonum float 2. ;;
#P preset 909 53 17 171;
#P user jit.pwindow 47 401 158 118 0 1 0 0 1 0;
#P window setfont “Fixedwidth Serif” 10.;
#P message 710 371 148 1441802 paintoval 64 23 256 215;
#P window setfont “Sans Serif” 9.;
#P newex 710 396 111 196617 jit.lcd 4 char 320 240;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 150 336 136 1441802 jit.op @op + @val 255;
#P newex 48 308 26 1441802 t b;
#P newex 48 336 79 1441802 jit.pack 4;
#P newex 48 280 104 1441802 jit.unpack 4;
#P newex 48 365 112 1441802 jit.alphablend;
#B color 5;
#P message 177 35 118 1441802 read countdown.mov;
#P window setfont Times 10.;
#P comment 32 36 39 1310730 Display;
#P comment 802 224 43 1310730 Initialize;
#P comment 432 288 59 1310730 Interpolation;
#P comment 528 239 13 1310730 y;
#P comment 452 239 13 1310730 x;
#P comment 441 225 68 1310730 Location offset;
#P comment 445 164 61 1310730 Anchor point;
#P comment 528 178 13 1310730 y;
#P comment 452 178 13 1310730 x;
#P comment 517 118 13 1310730 y;
#P comment 452 118 13 1310730 x;
#P comment 487 95 80 1310730 (both dimensions);
#P comment 420 95 32 1310730 Zoom;
#P window setfont “Fixedwidth Serif” 10.;
#P message 482 137 62 1441802 zoom_y \$1;
#P message 417 137 62 1441802 zoom_x \$1;
#P flonum 455 51 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname zoom;
#P flonum 482 118 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname zoom_y;
#P flonum 417 118 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname zoom_x;
#P number 493 239 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname offset_y;
#P number 417 239 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname offset_x;
#P toggle 417 287 15 0;
#P objectname interp;
#P message 417 305 62 1441802 interp \$1;
#P window linecount 3;
#P message 582 274 406 1441802 setname anchor_x , 160 , setname anchor_y , 120 , setname boundmode , 1 , setname interp , 1 , setname zoom , 3. , setname theta , 0. , setname target_time , 1000 , setname baseposx , 160 , setname baseposy , 120;
#P window linecount 1;
#P newex 749 325 32 1441802 pvar;
#P newex 749 221 53 1441802 loadbang;
#P number 493 178 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname anchor_y;
#P number 417 178 35 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname anchor_x;
#P message 493 258 73 1441802 offset_y \$1;
#P message 417 258 73 1441802 offset_x \$1;
#P message 493 197 73 1441802 anchor_y \$1;
#P message 417 197 73 1441802 anchor_x \$1;
#P message 33 125 53 1441802 theta \$1;
#P toggle 17 35 15 0;
#P newex 17 53 53 1441802 metro 50;
#P newex 30 174 53 1441802 jit.rota;
#B color 5;
#P newex 17 82 130 1441802 jit.qt.movie 320 240;
#P flonum 33 107 53 10 0 0 0 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname theta;
#P window setfont “Sans Serif” 9.;
#P comment 928 56 100 196617 this is ok;
#P connect 5 0 4 0;
#P connect 4 0 2 0;
#P fasten 38 0 2 0 182 55 81 55 81 78 22 78;
#P fasten 2 0 3 0 22 154 35 154;
#P fasten 6 0 3 0 38 145 35 145;
#P fasten 23 0 3 0 422 156 413 156 413 145 35 145;
#P fasten 24 0 3 0 487 156 413 156 413 145 35 145;
#P fasten 7 0 3 0 422 216 413 216 413 145 35 145;
#P fasten 8 0 3 0 498 216 413 216 413 145 35 145;
#P fasten 9 0 3 0 422 277 413 277 413 145 35 145;
#P fasten 10 0 3 0 498 277 413 277 413 145 35 145;
#P fasten 16 0 3 0 422 324 413 324 413 145 35 145;
#P connect 1 0 6 0;
#P fasten 3 0 40 0 35 275 53 275;
#P connect 40 0 42 0;
#P connect 44 0 41 0;
#P connect 42 0 41 0;
#P connect 41 0 39 0;
#P connect 39 0 46 0;
#P connect 40 1 41 1;
#P connect 40 2 41 2;
#P connect 40 3 41 3;
#P fasten 3 0 43 0 35 275 155 275;
#P connect 43 0 39 1;
#P fasten 22 0 20 0 460 114 422 114;
#P connect 20 0 23 0;
#P connect 11 0 7 0;
#P connect 18 0 9 0;
#P connect 17 0 16 0;
#P fasten 22 0 21 0 460 114 487 114;
#P connect 21 0 24 0;
#P connect 12 0 8 0;
#P connect 19 0 10 0;
#P connect 13 0 15 0;
#P connect 13 0 45 0;
#P connect 4 0 44 0;
#P connect 45 0 44 0;
#P connect 15 0 14 0;
#P pop;

#27355
Aug 28, 2006 at 7:41pm

On Aug 28, 2006, at 10:08 AM, jln wrote:

>
> I’m trying to move a picture with jit.rota using the offset
> arguments. This picture is composed with a circular zone, then
> passing thru a circular mask. How can I keep the playing picture
> inside the surface of the mask. I think there should be a way to do
> this mathematicaly, but the problem is that my math skill sucks
> (furthermore, I’m quite new to Jitter so maybe I went the wrong
> way). Any help would be greatly appreciated.

Well, you’ll want to brush up on your math if you want to do this
sort of thing. Just handling offset and zoom is quite easy (make sure
that offset + zoom*dimensions is within the bounding rectangle of
points and rotation, though it doesn’t require anything more than a
little algebra and trigonometry. (There are some free math tutorial