Le vendredi 09 avril 2010 à 11:52 +0100, Andrew Faraday a écrit : > > > > Date: Fri, 9 Apr 2010 11:03:28 +0200 > > From: zmoel...@iem.at > > To: jbtur...@hotmail.com > > CC: cinet...@passport.ca; pd-list@iem.at > > Subject: Re: [PD] gemmouse and pix_data > > > > Andrew Faraday wrote: > > > Quick and simple solution to a lot of similar problems, use > [range]. > > > > > > It needs four arguments, the input range (in this case 0 to the > size of your gemwin) as two arguments, and the output range (usually > -4 to 4) and it will convert one into the other. Although to make this > work on gem you need one for each of the x and y axes. > > > > > > You can do this by re-scaling yourself, although this does take > more time and effort, but also can provide more control. In the end > it's your own choice. > > > > > > > [gemmouse] will output coordinates in pixels by default. > > however, you can specify the range manually, [gemmouse 1 1] will > output > > x=0..1 and y=0..1 > > > > fgmsadr > > IOhannes > > > > I'm not entirely sure, but this would probably still be centred on the > top left corner of the gem window, so would still require some > arithmetic to sync up objects to mouse position. No, if you read the help about [pix-data], you only need the range between 0 and 1 : The coordinates within the image (x-pos, y-pos) range from (0.0f, 0.0f) (left-bottom) to (1.0f, 1.0f) (right-top). So [gemmouse 1 1] is enough (on Linux you have to invert the values on Y axe). Your example is good for a square GEM window and return the position in its space (not in the pix 'space' of a picture). (I'm not sure to be clear here ?) Have a look at the attached patch. ++
Jack > Something like > > [gemmouse 8 8] > | | > [- 4] [- 4] > > > > ______________________________________________________________________ > Get a free e-mail account with Hotmail. Sign-up now. > _______________________________________________ > Pd-list@iem.at mailing list > UNSUBSCRIBE and account-management -> > http://lists.puredata.info/listinfo/pd-list
#N canvas 592 25 620 485 10; #X obj 221 237 pix_data; #X msg 56 76 destroy; #X floatatom 312 289 5 0 0 0 - - -; #X floatatom 277 289 5 0 0 0 - - -; #X floatatom 243 289 5 0 0 0 - - -; #X obj 243 266 unpack f f f; #X obj 202 48 gemhead; #X obj 202 108 pix_image; #X obj 269 53 openpanel; #X msg 269 77 open \$1; #X obj 269 32 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 202 347 square 4; #X obj 202 317 pix_texture; #X obj 202 137 t a b a; #X obj 46 105 gemwin; #X obj 251 160 gemmouse 1 1; #X obj 266 188 - 1; #X obj 266 208 * -1; #X obj 422 48 gemhead 51; #X obj 422 189 translateXYZ; #X obj 462 125 * -1; #X obj 445 82 gemmouse 8 8; #X obj 462 105 - 4; #X obj 445 150 - 4; #X msg 46 46 cursor 0 \, create \, 1; #X obj 422 270 curve 2; #X msg 441 222 -0.1 0 0; #X msg 461 245 0.1 0 0; #X obj 422 380 curve 2; #X msg 441 332 -0.1 0 0; #X msg 461 355 0.1 0 0; #X obj 422 299 rotateXYZ 0 0 90; #X obj 524 188 loadbang; #X connect 0 1 5 0; #X connect 1 0 14 0; #X connect 5 0 4 0; #X connect 5 1 3 0; #X connect 5 2 2 0; #X connect 6 0 7 0; #X connect 7 0 13 0; #X connect 8 0 9 0; #X connect 9 0 7 0; #X connect 10 0 8 0; #X connect 12 0 11 0; #X connect 13 0 12 0; #X connect 13 1 0 0; #X connect 13 2 0 1; #X connect 15 0 0 2; #X connect 15 1 16 0; #X connect 16 0 17 0; #X connect 17 0 0 3; #X connect 18 0 19 0; #X connect 19 0 25 0; #X connect 20 0 19 2; #X connect 21 0 23 0; #X connect 21 1 22 0; #X connect 22 0 20 0; #X connect 23 0 19 1; #X connect 24 0 14 0; #X connect 25 0 31 0; #X connect 26 0 25 1; #X connect 27 0 25 2; #X connect 29 0 28 1; #X connect 30 0 28 2; #X connect 31 0 28 0; #X connect 32 0 26 0; #X connect 32 0 27 0; #X connect 32 0 29 0; #X connect 32 0 30 0;
_______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list