Colornames to RGB values; was: Re: Illustrating the message path in documentation

Wilhelm Sanke sanke at hrz.uni-kassel.de
Tue Dec 3 16:56:00 EST 2002


On Mon, 02 Dec 2002 Richard Gaskin <ambassador at fourthworld.com> wrote:


> > (4) How to get the rgb version of a Color specified by name.
> > That is, set the backgroundColor to "Violet1", say.
> > and then, scripted, set the foregroundcolor to something slightly
> > different.
> > Or, to get the backgroundColor in rgb, no matter how it was
> > entered.
>
> This is a basically unsolved problem. Rev just uses a lookup table to
> get color names vs RGB values. Unfortunately, when you then query the
> color of something that was set using a name, it returns the name and
> not the RGB values.
> If you want to find the complete list, open up the Application Overview
> and turn on Revolution UI stacks in list. Find revColors.rev and go to
> the only card in the only stack. Have a look at the properties and go
> to the Custom tab, then turn on "Show Revolution UI custom properties".
> The cRevColorTranslation property gives you all the names & RGB
> equivalents.
>
This is indeed not a "basically unsolved problem", but a hard to find
solution. You can find a solution in the script of the Metacard "color
chooser" and adapt it to your needs.
Let`s assume you have set the backcolor of your button 8 with a
colorname like "Aliceblue". Then you get the corresponding RGB value
with the following script:

on mouseUp
  get the effective backPixel of button 8
  set the backColor of button 8 to empty
  set the backPixel of button 8 to it
  put the  backcolor of btn 8
end mouseUp

Hope this information helps.

Regards,

Wilhelm Sanke




More information about the Use-livecode mailing list