Equivalence of Color names to RGB

J. Landman Gay jacque at hyperactivesw.com
Sun Jul 4 01:29:15 CDT 2004


On 7/3/04 10:01 PM, Alejandro Tejada wrote:

> Hi developers,
> 
> I've almost finished a handler to export
> vector graphics from RR/MC to Adobe Ilustrator
> version 7 file format, but i need a table
> of equivalences between rgb and the color names,
> for example: AliceBlue = 239,247,255.
> 
> How could i convert the color names to their
> equivalent rgb triplet?

Wilhelm Sanke posted the following a long time ago. I hope he doesn't 
mind my re-posting it here, or the fact that I have changed his original 
command handler to a function:

function colorToRGB which
   set the backcolor of fld "hiddenfield" to which
   get the effective backPixel of fld "hiddenfield"
   set the backPixel of field "Hiddenfield" to it
   return the  backcolor of fld "Hiddenfield"
end colorToRGB

You can use a hidden field if you don't want the conversion to show. If 
you are just doing this once during development, then you can use any 
object, hidden or not. Go through the colorNames() and apply the 
function to each one.

I thought this was a very clever script; setting the backpixel forces 
the color name to its equivalent RGB value.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list