Get the RGB values for the pixel under the mouse.

James Hurley jhurley0305 at sbcglobal.net
Sat Jul 21 10:00:32 CDT 2007


Thanks Glen. Color is in the mind of "if...then"

Jim


> Jim,
>
> Here is some of my dumb ways to check for some particular colors in
> one of my games.
>
> I thought it might give you some ideas.
>
>
> function pixelColor lx
>    set the screenMouseLoc to lx
>    get the mouseColor
>    set the screenMouseLoc to 0,0
>    return it
> end pixelColor
>
> -- c is the RGB values as an item list
> function isGreen c
>    if item 2 of c > 10+item 1 of c and item 2 of c > 10+item 3 of c
> then return true
>    return false
> end isGreen
>
> function isBrown c
>    if item 1 of c > 30 and item 1 of c < 70 and item 2 of c > 15 and
> item 2 of c < 40\
>    and item 3 of c > 7 and item 3 of c < 20 then return true
>    return false
> end isBrown
>
> function isYellow c
>    if c = "174,144,96" or c = "161,125,76" then return true
>    return false
> end isYellow
>
> function isBeige c
>    if item 1 of c > 130 and item 1 of c < 160 and item 2 of c > 90
> and item 2 of c < 130\
>    and item 3 of c > 40 and item 3 of c < 80 then return true
>    return false
> end isBeige
>
> Have fun,
> Glenn




More information about the use-livecode mailing list