Created
March 29, 2016 17:56
-
-
Save dxslly/499ae4e8a7ec78bfec3b75fb65413045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set the RGB16bit_list to (choose color default color {65535, 50584, 0}) | |
-- convert choosen color to HEX with leading # | |
set the formatedColor to my RBG_to_HEX(RGB16bit_list) | |
set the clipboard to formatedColor | |
on RBG_to_HEX(RGB_values) | |
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"} | |
set the the hex_value to "" | |
repeat with i from 1 to the count of the RGB_values | |
set this_value to (item i of the RGB_values) div 256 | |
if this_value is 256 then set this_value to 255 | |
set x to item ((this_value div 16) + 1) of the hex_list | |
set y to item (((this_value / 16 mod 1) * 16) + 1) of the hex_list | |
set the hex_value to (the hex_value & x & y) as string | |
end repeat | |
return (hex_value) | |
end RBG_to_HEX | |
on RBG_to_RGB8bit({r, g, b}) | |
set r to (r ^ 0.5) div 1 | |
set g to (g ^ 0.5) div 1 | |
set b to (b ^ 0.5) div 1 | |
return "{class:8-bit RGB color, red:" & r & ", green:" & g & ", blue:" & b & "}" as string | |
end RBG_to_RGB8bit | |
on RBG_to_RGB16bit({r, g, b}) | |
return "{class:16-bit RGB color, red:" & r & ", green:" & g & ", blue:" & b & "}" as string | |
end RBG_to_RGB16bit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment