Colors conversion (was [INFO] Javascript Colors list)

Eric Chatonet eric.chatonet at sosmartsoftware.com
Sat May 28 03:48:14 EDT 2005


Hi Tom,

 From my Color Picker plugin, here are some functions that may help:

function AnyColorToRGB pColor
   if comma is not in pColor then
     put ColorNameToRGB(pColor) into pColor -- Æ
     if pColor = empty then
       put HTMLToRGB(pColor) into pColor -- Æ
     end if
   end if
   return pColor
end AnyColorToRGB
-----------------------------
function ColorNameToRGB pColorName
   local tColors
   ------
   if pColorName is not among the lines of the colorNames then return  
empty
   put the uColors of this stack into tColors
   filter tColors with pColorName & ",*"
   return item 2 to 4 of tColors
end ColorNameToRGB
-----------------------------
function HTMLToRGB pHtmlRef
   if char 1 of pHtmlRef is "#" then delete char 1 of pHtmlRef
   -----
   return baseconvert(char 1 to 2 of pHtmlRef,16,10) & comma \
       & baseconvert(char 3 to 4 of pHtmlRef,16,10) & comma \
       & baseconvert(char 5 to 6 of pHtmlRef,16,10)
end HTMLToRGB

The uColors property returns a list of the color names followed by  
the rgb values.
I am going to post it separately in 2 mails because of the mail size  
limits on this list...

If you need another functions as RGBToHTML, RGBToColorName, etc. let  
me know :-)

Le 28 mai 05 ˆ 05:33, Thomas McGrath III a Žcrit :

> I did write a small script to get the RGB equivalent of those names  
> and posted the results. Maybe there is a function for that?
> I didn't find a way to do the HTML Hex values though. Any ideas?


Best regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Plugins, tutorials and more on our website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------



More information about the use-livecode mailing list