Created
August 5, 2012 15:40
-
-
Save dansimau/3265482 to your computer and use it in GitHub Desktop.
A colour picker app for Mac OS X
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) | |
-- convert choosen color to HEX | |
set the formatedColor to my RBG_to_HEX(RGB16bit_list) | |
set the clipboard to formatedColor | |
display dialog "HEX colour value (" & formatedColor & ") has been copied to the clipboard." with icon 1 buttons {"Dismiss"} default button {"Dismiss"} giving up after 10 | |
on RBG_to_HEX(RGB_values) | |
-- this subroutine was taken from "http://www.apple.com/applescript/sbrt/sbrt-04.html" | |
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 (the hex_value) | |
end RBG_to_HEX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment