Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Determine brightness of colour/Convert to GrayLevel

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89512] Re: [mg89485] Determine brightness of colour/Convert to GrayLevel
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Wed, 11 Jun 2008 03:19:49 -0400 (EDT)
  • References: <200806101114.HAA18927@smc.vnet.net> <484E695C.6070909@wolfram.com>

On Tue, Jun 10, 2008 at 14:45, Carl Woll <carlw at wolfram.com> wrote:
> Szabolcs Horvát wrote:
>
>> Colours have several representations, such as RGBColor, CMYKColor,
>> GrayLevel, etc.
>>
>> Is there a way to convert between these representations?  More
>> specifically is there a way to convert a colour to GrayLevel?  I would
>> like to determine the "brightness" of a colour to decide whether to
>> display text in black or in white on top of it.
>>
>> Also, is there a way to convert a colour to some canonical
>> representation?  A workaround I found is Lighter[colour, 0], which
>> converts to RGBColor, but I was hoping that there exists a function
>> meant specifically for conversion (and not
>> blending/lightening/darkening).
>>
>
> Try ToColor:
>
> ?ToColor
>
> ToColor[color, form] converts color to form if form is GrayLevel, RGBColor
> or CMYKColor. Otherwise form[color] is evaluated and the result \
> is expected to be a valid color directive.
>

Thanks!  That's exactly what I was looking for.


  • Prev by Date: Re: ConditionNumber
  • Next by Date: Re: Transform list of numbers into pure functions using
  • Previous by thread: Re: Determine brightness of colour/Convert to GrayLevel
  • Next by thread: Re: Determine brightness of colour/Convert to GrayLevel