Colour of a pixel?

Garrett Hylltun garrett at paraboliclogic.com
Wed Jul 12 23:02:45 EDT 2006


On Jul 12, 2006, at 6:35 PM, John Tregea wrote:

> Hi again,
>
> Can anyone tell me if there is a way of getting the rgb value of a  
> specified pixel within a jpg graphic file that has been imported  
> into rev?
>
> I have read the docs but cannot see anything that tells me if I can  
> or how...

The two items needed are....

mouseColor function:
Returns the color of the pixel that the mouse pointer is over.

screenMouseLoc property:
Specifies the position of the mouse pointer relative to the screen.   
(Also allows you to set the mouse to a specified location)

Example:

   put the screenMouseLoc into varMouseCoordinates
   put the left of this stack + 225 into varStackH
   put the top of this stack + 40 into varStackV
   set the screenMouseLoc to varStackV,varStackH
   put the mouseColor into varColor
   set the screenMouseLoc to varMouseCoordinates
   answer varColor

Grab the current location of the mouse, then get the left position of  
the stack and add how many pixels to the position that you need to  
the pixel you want, and then top of your stack plus how many pixels  
to the pixel you need, then move the mouse to that position, then  
using the mouseColor, get the color of that pixel, then put the mouse  
back where it was when you started.

-Garrett




More information about the use-livecode mailing list