Convert ColorNames to RGB
joel.guillod at net2000.ch
Mon Aug 29 13:10:31 CDT 2005
> The other way around is harder - you have to script / use a lookup
Not so hard to build a map between ColorNames and RGB: create a field
and name it "fColors", then put the following script in the card
script and type build in the message box: now the field display for
each color a line with: its colorname, a color rectangle, the color
value for html, the RGB value.
For lazy one, download a ready made stack "ColorNames Displayed" is
available under Revolution online, user "imed". Enjoy!
set cursor to watch
set the itemdel to tab
put empty into fld "fColors"
repeat for each line c in colornames()
put c & tab & " " &tab after fld "fColors"
set the backgroundcolor of char 1 to -1 of item 2 of last line
of fld "fColors" to c
put the backgroundcolor of item 2 of last line of fld "fColors"
put htmlColor(tColor) &tab& rgbColor(tColor) &cr after fld
function htmlColor c
put "#" into r
repeat for each item i in c
if len(it)=1 then put "0" after r
put it after r
function rgbColor c
return format("%03s,%03s,%03s",item 1 of c,item 2 of c, item 3 of c)
More information about the use-livecode