Trying to get the color at an xy location
Paul Hibbert
paulhibbert at mac.com
Tue Oct 7 15:31:54 EDT 2014
Bill,
Some solutions were posted a while ago for this, I made a copy of one that uses the templateImage so I'm not taking any credit, but here's the script:
on mouseUp
put readPixelColor(pLoc) into fld "Colour" -- Where pLoc is a local coordinate e.g. "200,200"
end mouseUp
function readPixelColor pVal
put globalLoc(pVal) into pVal
put item 1 of pVal + 1 into item 3 of pVal
put item 2 of pVal + 1 into item 4 of pVal
export snapshot from rect pVal to templateImage
get the imageData of templateImage
reset templateImage
return byteToNum(char 2 of it) & "," & byteToNum(char 3 of it) & "," & byteToNum(char 4 of it)
end readPixelColor
and another way posted by Jacque:
on getPixelColor pPt
put the screenmouseloc into tOldLoc
put (item 1 of pPt) + (the left of this stack) into tloc
put (item 2 of pPt) + (the top of this stack) into item 2 of tloc
set the screenmouseloc to tloc
put the mousecolor into tColor
set the screenmouseloc to tOldLoc
return tColor
end getPixelColor
It happens so fast the mouse never moves. Based on a suggestion by Dr Raney.
HTH
Paul
On Oct 7, 2014, at 11:50 AM, William Prothero <prothero at earthednet.org> wrote:
> Folks:
> I’m trying to the the color under an xy location on my stack. I did it once by sripting a move of the mouse to that location and using mouseColor to get the odor. I’ve forgotten how I did it and can’t get it to work.
>
> I’m on Mac OSX, 10.9.5 and livecode 7.0 rc2.
>
> Anybody remember the command for setting the mouseLoc in script?
> Tnx,
> Bill
>
> William A. Prothero
> http://es.earthednet.org/
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list