Converting Rev color to HTML color?
Ken Ray
kray at sonsothunder.com
Fri Nov 29 21:48:01 EST 2002
Dave,
Here's the conversion code I use - note it's a little funky when it comes to
making sure that "0" is really "00", but it works:
on mouseUp
answer color
if it <> "" then
put ConvertToHex(it)
end if
end mouseUp
function ConvertToHex pRGB
set the numberFormat to "00"
put "" into retVal
repeat with x = 1 to 3
put baseConvert(item x of pRGB,10,16) into tVal
if isNumber(tVal) then
put tVal + 0 after retVal
else
put tVal after retVal
end if
end repeat
return "#" & retVal
end ConvertToHex
The reason for the "put tVal + 0 after retVal" is that in order to force a
number to adopt the numberFormat, you need to do some kind of math
calculation on it; adding 0 is the best way to do that.
Hope this helps!
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
----- Original Message -----
From: "David Egbert" <degbert at mac.com>
To: <use-revolution at lists.runrev.com>
Sent: Saturday, November 30, 2002 1:06 AM
Subject: Converting Rev color to HTML color?
> I'm trying to convert the color returned from Answer Color to a HTML-style
> color. Is there a function that will do that? I tried using "answer
color
> with #FFFFFF" in hopes it would return HTML color, but that didn't work.
>
> Any ideas?
>
> Many thanks to this wonderful group in helping me get up to speed with
Rev!
>
>
> --
> Dave Egbert
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list