finding the mousecolor in IOS

Howard Bornstein bornstein at designeq.com
Thu Jul 12 19:23:33 EDT 2012


On Thu, Jul 12, 2012 at 3:18 PM, Scott Rossi <scott at tactilemedia.com> wrote:

> Hi Howard:
>
> It seems the mouseColor is not functional on iOS in 5.5.1 (but apparently
> it
> has been fixed on Lion which is a huge relief).
>

I don't understand this because you are comparing IOS and Lion. MouseColor
already works fine in OSX. Do you mean that if you compile an IOS app under
Lion, then mouseColor will work? Is this a RunRev change or does it have
something to do with OSX?

As I pointed out, given that IOS can identify a pixel point, I don't see
any technical reason why it can't grab the color of that point (using
mouseColor). I will check with the mother ship to see if I can get any
clarity on this

>
> That said, if you can work with an image as your color source (ie import a
> snapshot if needed), you can use the following function as a workaround
> (watch wrap):
>

THANK YOU SCOTT! I thought this might be a way to proceed, but since I
really don't know my way around imageData, I was despairing to undertake
the experiment. You've saved me a huge amount of time.


> local theImageData
>
> function getPixelColor pImage,pX,pY
>    if theImageData is empty then put the imageData of pImage into
> theImageData
>    put width of pImage into W
>    put ((pY-1)*W)*4+pX*4 into lastChar
>    put charToNum(char lastChar of theImageData) into B
>    put charToNum(char lastChar-1 of theImageData) into G
>    put charToNum(char lastChar-2 of theImageData) into R
>    return R,G,B
> end getPixelColor
>
>
> This should retrieve the color of a pixel in a target image based on the
> X,Y
> offset of the touch from the topLeft.  The idea is to store the imageData
> of
> the target image in theImageData variable so the function doesn't have to
> retrieve it repeatedly.
>
> I've been wanting mouseColor on iOS myself and while not true mouseColor,
> this comes close.  Hope this helps.
>

I did a quick test of this, outputting the color from both your function
and from mouseColor to compare. While your function is close, it isn't
giving me the same colors as mouseColor. I will have to go back and see if
I didn't do something stupid, but the truth is, for the level of
granularity I need, your function will work, even if it isn't exactly the
same as mouseColor.

Thank you again. This is a BIG help!


> Recently, Howard Bornstein wrote:
>
> > I'm designing a an IOS app that makes extensive use of determining "the
> > mousecolor". Everything is working fine in my stack, but when I port it
> to
> > the simulator (or create the IOS app), the mousecolor only returns 0,0,0
> > regardless of where the mouse is.
> >
> > I found some early posts from last year discussing this issue and they
> > conclude that the mousecolor can't be supported under IOS because there
> is
> > no way to determine which pixel is being specified (I guess because our
> > fingers are fatter than a single pixel).
> >
> > However, this doesn't make sense. If you put this script into the card
> of a
> > stack and run it in the simulator (it also works in an actual IOS app),
> it
> > gives you the point your finger is pressing on the iphone:
> >
> > *on* mousemove
> >
> >     *put*  the mouseloc &&":"&& the mousecolor into fld "location"
> >
> > *end* mousemove
> >
> > However, the mousecolor, as I mentioned, is always black. Since LC can
> > determine a specific pixel (or at least aggregates the points you are
> > touching down to a specific pixel) it doesn't seem like there is any
> reason
> > it can't get the mousecolor under that pixel.
> >
> > In addition, I found this comment in the release notes for IOS 4.5.3:
> >
> > *release-17 (2010-12-01)*
> >
> > **
> >
> > *Fixed issue with 'the mouseColor' causing a crash*
> >
> >
> > This implies to me that the mousecolor is supported under IOS. So, has
> > anyone gotten this to work or has anyone found another way to get the
> > mousecolor for a point on an IOS screen?
>
>
>



More information about the use-livecode mailing list