finding the mousecolor in IOS

Peter M. Brigham pmbrig at gmail.com
Sat Jul 14 11:00:22 EDT 2012


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
pmbrig at gmail.com
http://home.comcast.net/~pmbrig





More information about the use-livecode mailing list