Color at a location on the screen

Matt Denton matt.denton at limelight.com.au
Thu Jan 30 21:53:01 EST 2003


Hi Klaus

Thanks for the tip, I thought of doing something like this but the ol' 
mouse would be jumping around all over the place.

I worked out a compromise: because I knew the object I wanted to get 
the colors from, I grabbed the imageData and worked out the RGB value 
from the raw data:

on setPixelColor pThisPixelH
   put (pThisPixelH - left of image "Rainbow.png"+1)*4 into tLeftOffset 
-- four bytes per pixel
   put charToNum(char tLeftOffset +2 of tColors) into tRed -- 2nd byte 
is the lovely red dot
   put charToNum(char tLeftOffset +3 of tColors) into tGreen -- 3rd byte 
is the happy green spot
   put charToNum(char tLeftOffset +4 of tColors) into tBlue -- 4th byte 
is the calm blue dot
   set the backColor of the target to tRed,tGreen,tBlue
end setPixelColor

I'm sure I could optimize this somehow (seems odd converting charToNum 
for data that is then converted back again) but it works.  Anyway all 
the info is in the manual under imageData ;-)  I just fiddled with it 
for a bit till it worked for me.

Thanks again Klaus.

>> I seem to recall an external or was I thinking of another script
>> language?
>
> Cobol? ;-)

hehe... not in a million years ;-0   I'm a Xtalk dummy (bit of assembly 
and even raw hex in machine code back in the dark ages...twas tedious 
but fun).

Chow,

M@
Matt


> check the "screenmouseloc

> " entry in the index.
>
> You could store the old mouseloc, set the screenmouseloc to the desired
> point inside your clear circle, get the mousecolor and set the mouseloc
> to its old loc again...
>
> Just a thougth, but should be doable...
>
> Hope that helps.

>
>> Does anyone know how to find the color at a location on the screen?
>>
>> I've got a small clear circle that drags constrained horizontally over
>> a color bar to select a color. The mouseColor works perfectly as long
>> as the cursor is over the color, but as the clear circle is
>> constrained to the color bar, the cursor can really be anywhere.  So I
>> need to find the color at a location, ie where the circle is on the
>> color bar.  I've searched under 'screen', 'loc', 'cursor', 'color' and
>> every other combination I can think of.




More information about the use-livecode mailing list