Convert ColorNames to RGB
Joel Guillod
joel.guillod at net2000.ch
Mon Aug 29 14:10:31 EDT 2005
> The other way around is harder - you have to script / use a lookup
> table.
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!
Joel G
on build
set cursor to watch
lock screen
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"
into tColor
put htmlColor(tColor) &tab& rgbColor(tColor) &cr after fld
"fColors"
end repeat
end build
function htmlColor c
put "#" into r
repeat for each item i in c
get baseconvert(i,10,16)
if len(it)=1 then put "0" after r
put it after r
end repeat
return r
end htmlColor
function rgbColor c
return format("%03s,%03s,%03s",item 1 of c,item 2 of c, item 3 of c)
end rgbColor
More information about the use-livecode
mailing list