Created
June 9, 2011 17:34
-
-
Save robmooney/1017244 to your computer and use it in GitHub Desktop.
Generate a UIColor with the colour panel from right inside Xcode
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
(* | |
Generate a UIColor with the colour panel from right inside Xcode | |
To install place in ~/Library/Scripts/Applications/Xcode/ and enable the Script | |
menu in AppleScript preferences (or use FastScripts) | |
Limitations: | |
Doesn't support alpha values | |
*) | |
set the_color to choose color | |
tell front document of application "Xcode" to activate | |
set prev_clipboard to the clipboard | |
set the clipboard to ¬ | |
"[UIColor colorWithRed:" & rgb_value(item 1 of the_color) & ¬ | |
"f green:" & rgb_value(item 2 of the_color) & ¬ | |
"f blue:" & rgb_value(item 3 of the_color) & ¬ | |
"f alpha:1.0f]" | |
tell application "System Events" to keystroke "v" using command down | |
delay 3 | |
set the clipboard to prev_clipboard | |
on rgb_value(num) | |
set raw_value to num / 65535 | |
return ((raw_value * 1000) as integer) / 1000.0 | |
end rgb_value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment