ColorAtScreenLoc Function

Mark Schonewille m.schonewille at economy-x-talk.com
Tue Jan 21 15:36:55 EST 2014


Hi Ray,

Now I'm thinking, why did I write a function for the screenLoc only? So, 
here's a general solution.

// usage: pointColor("100,200") or
// pointColor(100,200) or e.g.
// pointColor(the screenLoc)
function pointColor thePoint
    if the paramCount is 2 then
       put param(1),param(2) into thePoint
    end if
    put thePoint into myLoc
    add 31 to item 1 of myLoc
    add 31 to item 2 of myLoc
    put thePoint,myLoc into myRect
    export snapshot from rectangle myRect to myPixels as PNG
    set the text of the templateImage to myPixels
    put char 1 to 4 of the imageData of the templateImage into myPixel
    reset the templateImage
    return charToNum(char 2 of myPixel), \
      charToNum(char 3 of myPixel),charToNum(char 4 of myPixel)
end pointColor

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

Fill out this survey please
http://livecodebeginner.economy-x-talk.com/survey/

On 1/21/2014 20:04, Ray wrote:
> Mark - I believe this is everything I need.  Thanks!  I especially like
> you usage of the templateImage which keeps everything easy to work with
> and no cleanup needed.
>
> Ray





More information about the use-livecode mailing list