HTML Color Codes
Sarah Reichelt
sarah.reichelt at gmail.com
Sat Aug 9 17:21:27 EDT 2008
>> Sarah I had no idea the numbers were related like that, interesting thanks
>> for explaining. I tried out your function and mostly it worked, but
>> sometimes it outputs a less-than-6-digit html color which causes an error
>> when setting the backcolor of say a button to tHTMLcolor
>
> Take a look at the "numberformat" property. This property sets the number of
> digits both before and after a decimal point. There are lots of options, but
> the most important thing to remember is that it will not work unless you
> perform a mathematical action on the variable. If you don't want to change
> the variable's value, just add zero to it:
>
> put baseconvert(r,10,16) into r
> set the numberformat to "00"
> add 0 to r
>
> This gives you a two-digit number in all cases.
Will the numberFormat work with hexadecimal numbers?
That was my mistake in the function Heather, but my solution would be:
if the length of r < 2 then put "0" before r
And repeat this for g & b before assembling the HTML color string.
Cheers,
Sarah
More information about the use-livecode
mailing list