How can I control my mouse with mira.multitouch?
Hey,
I'm trying to get the rgb data of an image using miraweb.
I'm so far that I get using my mouse the rgb data with the saga object. I put the mira.multitouch object on it.
But how can I use the "touch data" (x/y coordinates) to get the matching rgb data from the saggah object?
Here's my patch:
Suckah object reports differently when clicked on, or when it gets coordinates to report.
In case of coordinates it reports SCREEN coordinates RGB, not max patch coordinates.
So if You send 0 0 to suckah it will report RGB at left top corner of the whole screen,
not max patch.
Now if You want to report RGB on some coordinates in Max Patch,
better say on mira.multitouch area, you have to make sure that max patch,
allways sits on same place on the screen, and then You need to offset and calculate
the coordinates.
Let's do some math :
if You want to report RGB of a Picture which has 200 x 200 pixels size,
and is placed at 100 100 position in max patch, which itself has left top corner
placed at 0 40 on the screen, then picture itself has area 100 140 300 340.
Now x y coordinates from mira.multitouch (which should exactly cover the picture),
should be scaled 0. 1. 100 300, and 0. 1. 140 340 .
I don't know which corner is reported 0 0 in mira.multitouch,
so maybe scaling has to be inverted.
You could also try automating this all, getting patch screen coordinates, and object coordinates...
Or does mira have this option ? Reporting absolute coordinates ?
So have fun with all of this.
Thank you! I don't think that mira has this option to report absolute coordinates.
Now I'm getting some colors, your help with the math was good, but it's hard to find the exact position of my image and the mira.multitouch object. You don't think that there is an easier way to do this?
You can set Your Image coordinates in the patch in it's inspector.
or with patching_rect message.
Covering Image with mira.multitouch should be easy.
Maybe that objects also accepts patching_rect message ?
Another option is using scripting, You set scripting name for fpic and mira like MYfpic and MYmira
then send message {script move MYfpic 100 100, script move MYmira 100 100}
to thispatcher object.
That would position top left corner of both objects to x y 100 100 in the patch.
Also {script size MYfpic 400 500 , script size MYmira 400 500} to resize them should work.
-----------------------------
And You can position the patch with window messages to thispatcher object.
{window size 0 44 800 800, window exec} for example.
If You want to lock the window, remove the title bar {window notitle, window exec}
put together {window size 0 22 800 800, window notitle, window exec}
Or the opposite, ask thispatcher to give You the patcher screen coordinates,
and calculate image coordinates from that.
Do You need a patch that does this ?
I mean the window pos and calculation ?
Yes thank's, I try my best, but a patch that does this would be great.
Ha,ha, i thought You would say so.
Nina, the best way to do stuff is" do it yourself", I am not sure if
the patches I'd post would be helping You or doing the opposite.
I understand that without knowing what max objects could do,
one has difficullties to solve tasks, but if I provide You with infos
about what You could use to do this or that, it should be enough.
So You have to do Your homework.
If it does not work, please post here
and I will post the patches with examples etc...
-----------
One could go easier path, so just ask what is not clear, for example
asssigning one max object a scripting name.Where does one do that ?
hi nina, i would use jit.matrix for this. you can output a jit.matrix from fpic simply by sending a bang. you can then query the color value at a specific coordinate by scaling the 0. to 1. range of multitouch coordinates by the matrix dimensions.
@Rob Ramirez thank you very much, that was exactly what i needed to finish my project!