Convert rgb to lightness or darkness

Ben Rubinstein benr_mc at cogapp.com
Thu Oct 9 05:38:48 EDT 2014


In the standard formula for RGB -> HSL (Hue, Saturation, Lightness), Lightness 
is calculated as the average of the max and min of the RGB values.  In the 
standard formula for RGB -> HSV (Hue, Saturation, Value), Value is the max of 
the RGB values.

I would guess one of those calculations would be closer to giving you the 
right answer than the total of R+G+B.

Ben

On 08/10/2014 09:21, Tiemo Hollmann TB wrote:
> Just a guess, didn't tried it.
> If you add the three RGB values of the mousecolor, white (light) would be
> 765 and black (dark) 0. Somewhere around 382 you can switch from black to
> yellow text.
> Tiemo
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] Im
> Auftrag
>> von William Prothero
>> Gesendet: Dienstag, 7. Oktober 2014 21:59
>> An: Use-livecode Use-livecode
>> Betreff: Convert rgb to lightness or darkness
>>
>> Folks:
>> I’m putting text on an image that will be turned into a snapshot. The
> image
>> goes from light to dark. The text is a one or two digit integer. I want it
> to
>> show up on the image. For dark parts of the image, I set it to yellow, but
> for
>> light parts of the image, I want to set it to black. Is there a simple
> formula
>> for changing an rgb value into a darkness value that will let me choose
>> between yellow or black text?  I don’t want to just set the ink of the
> text
>> because sometimes I write the text over itself, which diminishes the
> effect.





More information about the use-livecode mailing list