Re: finding the mousecolor in IOS

2012-07-14 Thread Peter M. Brigham
On Jul 13, 2012, at 9:11 AM, Colin Holgate wrote:

 One exercise in that book I wrote is about using an image as a color picker. 
 It uses the same technique as Scott mentioned, only I then set the color of 
 another graphic to show that it has picked up the right color.
 
 One thing to double check, the x and y values you're using, are those from 
 the top left of the image? With mousecolor you use the card position, but 
 with this imagedata technique you would subtract the left and top of the 
 image in question, unless the image is the whole card.

function relativeXY tObjRef,x,y
   -- input: x,y (card coordinates) 
   -- output: coordinates relative to an object's rect
   put the topleft of tObjRef into tl
   put item 1 of tl into baseHoriz
   put item 2 of tl into baseVert 
   return (x - baseHoriz  comma  y - baseVert)
end relativeXY

-- Peter

Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-13 Thread Colin Holgate
One exercise in that book I wrote is about using an image as a color picker. It 
uses the same technique as Scott mentioned, only I then set the color of 
another graphic to show that it has picked up the right color.

One thing to double check, the x and y values you're using, are those from the 
top left of the image? With mousecolor you use the card position, but with this 
imagedata technique you would subtract the left and top of the image in 
question, unless the image is the whole card.



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-13 Thread Howard Bornstein
On Fri, Jul 13, 2012 at 6:11 AM, Colin Holgate co...@verizon.net wrote:

 One exercise in that book I wrote is about using an image as a color
 picker. It uses the same technique as Scott mentioned, only I then set the
 color of another graphic to show that it has picked up the right color.


That's exactly what I'm doing. I'm using the color picker to set the color
of text, modifying the text color in real time as the user moves around the
color wheel by touch. Can you give more information about the book you
wrote? It sounds interesting.

One thing to double check, the x and y values you're using, are those from
 the top left of the image? With mousecolor you use the card position, but
 with this imagedata technique you would subtract the left and top of the
 image in question, unless the image is the whole card.


I'm assuming Scott's technique does this. His description is: This should
retrieve the color of a pixel in a target image based on the X,Y offset of
the touch from the topLeft.

I've been busy with other things and haven't been able to check to make
sure I haven't done something dumb with his code, but I've been assuming
that is how this works.

-- 
Regards,

Howard Bornstein
---
www.designeq.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


finding the mousecolor in IOS

2012-07-12 Thread Howard Bornstein
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?

-- 
Regards,

Howard Bornstein
---
www.designeq.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Howard Bornstein
On Thu, Jul 12, 2012 at 3:18 PM, Scott Rossi sc...@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?



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Colin Holgate
Try this line before doing the snapshot:

set the screengamma to 2.23

LiveCode changes the values in image data depending on the color settings of 
the screen, and doing a snapshot of the card's graphics is likely to lead to 
different data.


On Jul 12, 2012, at 7:23 PM, Howard Bornstein bornst...@designeq.com wrote:

 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.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Scott Rossi
If you're working with an imported or referenced image, it would probably
better to strip the gamma from the source image all together, using
something like ColorSync Utility or similar -- as mentioned by Tim Bobo --
rather than changing the gamma of the screen.  But if you're working with a
snapshot, you don't really have any other option.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design



Recently, Colin Holgate wrote:

 Try this line before doing the snapshot:
 
 set the screengamma to 2.23
 
 LiveCode changes the values in image data depending on the color settings of
 the screen, and doing a snapshot of the card's graphics is likely to lead to
 different data.
 
 
 On Jul 12, 2012, at 7:23 PM, Howard Bornstein bornst...@designeq.com wrote:
 
 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.
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Scott Rossi
Recently, Howard Bornstein wrote:

 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?

I mentioned this because until recently, mouseColor was broken on OSX Lion,
so you couldn't even use the function on desktop, not to mention iOS.  For
those of use that develop tools, this was a problem.  Fortunately, the
RunRev guys appeared to have fixed it.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Howard Bornstein
Ah, I see. Thanks for the clarification. I've been putting on switching to
Lion for as long as possible so I haven't seen that problem. I guess I'll
have to bite the bullet with Mountain Lion though.

On Thu, Jul 12, 2012 at 4:56 PM, Scott Rossi sc...@tactilemedia.com wrote:

 Recently, Howard Bornstein wrote:

  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?

 I mentioned this because until recently, mouseColor was broken on OSX Lion,
 so you couldn't even use the function on desktop, not to mention iOS.  For
 those of use that develop tools, this was a problem.  Fortunately, the
 RunRev guys appeared to have fixed it.

 Regards,

 Scott Rossi
 Creative Director
 Tactile Media, UX Design



 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode




-- 
Regards,

Howard Bornstein
---
www.designeq.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: finding the mousecolor in IOS

2012-07-12 Thread Howard Bornstein
I haven't had time to pursue any of this yet, but do you think the gamma
would explain why I'm getting different values with Scott's routine versus
the built-in mouseColor function? Btw, I'm using an imported image that I
haven't modified in any way.

This is all so I can build my own color picker for IOS.

On Thu, Jul 12, 2012 at 4:34 PM, Colin Holgate co...@verizon.net wrote:

 Try this line before doing the snapshot:

 set the screengamma to 2.23

 LiveCode changes the values in image data depending on the color settings
 of the screen, and doing a snapshot of the card's graphics is likely to
 lead to different data.


 On Jul 12, 2012, at 7:23 PM, Howard Bornstein bornst...@designeq.com
 wrote:

  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.

 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode




-- 
Regards,

Howard Bornstein
---
www.designeq.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode