Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Copy RGB or HEX color values from the Color Picker' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Copy RGB or HEX color values from the Color Picker
Authored by: NovaScotian on Mar 06, '08 08:16:33AM

I use this script to do it. It returns (in the clipboard) the BBCode, Decimal Number, or HTML code for the color chosen.

<code>set C10 to choose color default color {50000, 50000, 50000}
set Val16 to ""
repeat with C in C10
if contents of C = 0 then
set Val16 to Val16 & "00"
else
set Val16 to Val16 & |10->16|(C) -- as 8-bit colors
end if
end repeat

set B to button returned of (display dialog "The color values for the color chosen:" & return & return & Val16 default button 3 buttons {"BB to Clip", "Num to Clip", "HTML to Clip"})
if B = "BB to Clip" then
set the clipboard to "[color=#" & Val16 & "]"
else if B = "Num to Clip" then
set the clipboard to Val16
else
set the clipboard to "<font color=\"#" & Val16 & "\">"
end if

on |10->16|(n10)
set n10 to n10 div 256 -- to get 8-bit
if n10 is less than 0 then set n10 to -n10
set Ch16 to "0123456789ABCDEF"
set Txt16 to ""
set N to n10
set Dgt16 to 1
repeat
if N is 0 then exit repeat
set nx to N div Dgt16
set mx to nx mod 16
set Txt16 to (character (mx + 1) of Ch16) & Txt16
set N to N - (mx * Dgt16)
set Dgt16 to (Dgt16 * 16)
end repeat
if length of Txt16 = 1 then set Txt16 to "0" & Txt16
return Txt16
end |10->16|</code>



[ Reply to This | # ]