Tyler Eich Posted March 10, 2013 Share Posted March 10, 2013 (edited) Colors v2.0.0 Get it from Packal (Recommended) Quick Summary: This workflow can process and convert all CSS color formats and several Objective-C formats, namely NSColor (calibrated and device) and UIColor. It also provides an interface to the OS X color panel for easier color manipulations. It's written in native code (i.e. it's really fast). Quick Preview: You can find a full description on Packal. Direct download • source code on Github Edited January 28, 2014 by Tyler Eich phyllisstein, Florian, MageCure and 13 others 16 Link to comment
jdfwarrior Posted March 10, 2013 Share Posted March 10, 2013 Well done sir. 'Color' me impressed. I intended to convert this one and make it essentially EXACTLY like this. You read my mind. Good work Tyler Eich 1 Link to comment
Tyler Eich Posted March 10, 2013 Author Share Posted March 10, 2013 Well done sir. 'Color' me impressed. I intended to convert this one and make it essentially EXACTLY like this. You read my mind. Good work Awesome! Please let me know if you have suggestions Arthur Melo 1 Link to comment
ctwise Posted March 11, 2013 Share Posted March 11, 2013 This is excellent, it's almost a complete replacement for Robert Horvath's Hex Color/Picker workflow. That version does one additional thing yours doesn't, it brings up the color picker when '#' is entered without a hex code. Here's the code it uses to either throw up the color picker or just pass on the hex code: if "{query}" == "pick" `OUTPUT=$(osascript -e 'tell application "Finder"' -e 'activate' -e 'choose color' -e 'end tell' | ruby -e 'puts "#" + STDIN.read.split(",").map{|y| "%.2x" % [y.to_i>>8]}.join'); printf $OUTPUT | pbcopy` else print "{query}" end Link to comment
ClintonStrong Posted March 11, 2013 Share Posted March 11, 2013 This is amazing. You win the internets. Oh, and adding to the color picker code ctwise posted, you could just add a bit of AppleScript to show the color in Alfred: OUTPUT=$(osascript -e 'tell application "Finder"' -e 'activate' -e 'choose color' -e 'end tell' | ruby -e 'puts "#" + STDIN.read.split(",").map{|y| "%.2x" % [y.to_i>>8]}.join'); printf $OUTPUT | pbcopy; osascript -e 'tell application "Alfred 2"' -e "search \"$OUTPUT\"" -e 'end tell' You can paste that code in to Terminal if you want to see it in action. Tyler Eich 1 Link to comment
ctwise Posted March 11, 2013 Share Posted March 11, 2013 This is amazing. You win the internets. Oh, and adding to the color picker code ctwise posted, you could just add a bit of AppleScript to show the color in Alfred: OUTPUT=$(osascript -e 'tell application "Finder"' -e 'activate' -e 'choose color' -e 'end tell' | ruby -e 'puts "#" + STDIN.read.split(",").map{|y| "%.2x" % [y.to_i>>8]}.join'); printf $OUTPUT | pbcopy; osascript -e 'tell application "Alfred 2"' -e "search \"$OUTPUT\"" -e 'end tell' You can paste that code in to Terminal if you want to see it in action. Yes, that's much better. A little experimentation shows that creating two script filters for '#' - one that requires arguments and one that doesn't allow them works very well. The one without arguments just displays a single entry to launch the color picker and trigger the above script. The other is untouched from the current workflow. Link to comment
jdfwarrior Posted March 11, 2013 Share Posted March 11, 2013 Yes, that's much better. A little experimentation shows that creating two script filters for '#' - one that requires arguments and one that doesn't allow them works very well. The one without arguments just displays a single entry to launch the color picker and trigger the above script. The other is untouched from the current workflow. Creating it as two script filters though makes it show as two items if the user hasn't typed a space yet though correct? If they have only typed '#' then it shows two seemingly identical pieces? Granted, the other would disappear as soon as you pressed space but still.. He could easily just add an if statement to check and see IF a value was passed to the function and if not, display the color picker, otherwise, convert the color passed. Unless I'm misunderstanding something... ? Tyler Eich 1 Link to comment
ctwise Posted March 11, 2013 Share Posted March 11, 2013 Creating it as two script filters though makes it show as two items if the user hasn't typed a space yet though correct? If they have only typed '#' then it shows two seemingly identical pieces? Granted, the other would disappear as soon as you pressed space but still.. He could easily just add an if statement to check and see IF a value was passed to the function and if not, display the color picker, otherwise, convert the color passed. Unless I'm misunderstanding something... ? Nope, you're correct. It's just a little simpler. Link to comment
capsella Posted March 11, 2013 Share Posted March 11, 2013 can you post an example of combining the 2 options for the hex script filter? Link to comment
Tyler Eich Posted March 12, 2013 Author Share Posted March 12, 2013 This is excellent, it's almost a complete replacement for Robert Horvath's Hex Color/Picker workflow. That version does one additional thing yours doesn't, it brings up the color picker when '#' is entered without a hex code. Here's the code it uses to either throw up the color picker or just pass on the hex code: if "{query}" == "pick" `OUTPUT=$(osascript -e 'tell application "Finder"' -e 'activate' -e 'choose color' -e 'end tell' | ruby -e 'puts "#" + STDIN.read.split(",").map{|y| "%.2x" % [y.to_i>>8]}.join'); printf $OUTPUT | pbcopy` else print "{query}" end This is amazing. You win the internets. Oh, and adding to the color picker code ctwise posted, you could just add a bit of AppleScript to show the color in Alfred: OUTPUT=$(osascript -e 'tell application "Finder"' -e 'activate' -e 'choose color' -e 'end tell' | ruby -e 'puts "#" + STDIN.read.split(",").map{|y| "%.2x" % [y.to_i>>8]}.join'); printf $OUTPUT | pbcopy; osascript -e 'tell application "Alfred 2"' -e "search \"$OUTPUT\"" -e 'end tell'You can paste that code in to Terminal if you want to see it in action. Creating it as two script filters though makes it show as two items if the user hasn't typed a space yet though correct? If they have only typed '#' then it shows two seemingly identical pieces? Granted, the other would disappear as soon as you pressed space but still.. He could easily just add an if statement to check and see IF a value was passed to the function and if not, display the color picker, otherwise, convert the color passed. Unless I'm misunderstanding something... ? can you post an example of combining the 2 options for the hex script filter?Thanks to everyone for their feedback! I like the color picker idea; I'm searching for the best way to implement it and using several of the suggestions that have been posted here.A conditional statement within my code feels like the cleanest solution; I was thinking of latching a 'show color picker' item for all script filters before any input is given (so 'rgb', 'hsl', '#', and 'c' without any code input would allow you to use the color picker). I am still deciding how the color should be used; should it be copied to the clipboard, fed back into Alfred, etc.? I'm leaning toward feeding the color back into Alfred, just so you have more control over what is copied. Comments are welcome Link to comment
ctwise Posted March 12, 2013 Share Posted March 12, 2013 Thanks to everyone for their feedback! I like the color picker idea; I'm searching for the best way to implement it and using several of the suggestions that have been posted here. A conditional statement within my code feels like the cleanest solution; I was thinking of latching a 'show color picker' item for all script filters before any input is given (so 'rgb', 'hsl', '#', and 'c' without any code input would allow you to use the color picker). I am still deciding how the color should be used; should it be copied to the clipboard, fed back into Alfred, etc.? I'm leaning toward feeding the color back into Alfred, just so you have more control over what is copied. Comments are welcome Feed back into Alfred. It lets you pick a color and then the representation. Tyler Eich 1 Link to comment
jdfwarrior Posted March 12, 2013 Share Posted March 12, 2013 Feed back into Alfred. It lets you pick a color and then the representation. The man makes a great point Link to comment
phyllisstein Posted March 12, 2013 Share Posted March 12, 2013 Thanks, that's great! And even handy for some of the LaTeX stuff I do. Tyler Eich 1 Link to comment
capsella Posted March 12, 2013 Share Posted March 12, 2013 +1 for feeding back into Alfred Tyler Eich 1 Link to comment
Tyler Eich Posted March 12, 2013 Author Share Posted March 12, 2013 I've updated the workflow to include my first attempt at a color picker; thanks to everyone for their feedback! http://cl.ly/2y1d2w1f0y1w capsella 1 Link to comment
capsella Posted March 12, 2013 Share Posted March 12, 2013 NICE!!! seems to be working perfectly Tyler Eich 1 Link to comment
Tyler Eich Posted March 13, 2013 Author Share Posted March 13, 2013 I've updated the workflow to include my first attempt at a color picker; thanks to everyone for their feedback! http://cl.ly/1A1U3n1d1H3S I found a var_dump() line in my code that broke HSL conversions . The workflow has been updated to fix that; try this link: http://cl.ly/2y1d2w1f0y1w DimerHunton 1 Link to comment
ClintonStrong Posted March 18, 2013 Share Posted March 18, 2013 Just a quick suggestion for the color picker: You can show the color picker with any application, not just Finder. You could even use Alfred 2 in the `tell` command. The main benefit is that it won't show any unrelated windows with the color picker, and you can easily bring it back up by invoking Alfred. This pretty much replaced the color picker application I used to use. Clicking the magnifying glass icon in the color picker replaces apps like ColorSnapper. Pretty cool. Link to comment
Tyler Eich Posted March 18, 2013 Author Share Posted March 18, 2013 Just a quick suggestion for the color picker: You can show the color picker with any application, not just Finder. You could even use Alfred 2 in the `tell` command. The main benefit is that it won't show any unrelated windows with the color picker, and you can easily bring it back up by invoking Alfred. This pretty much replaced the color picker application I used to use. Clicking the magnifying glass icon in the color picker replaces apps like ColorSnapper. Pretty cool. I remember trying this, but I couldn't get it to work; I'll give it another go, because I would love to not change app focus just to show a color picker. Does anybody know a way to include an opacity slider in the color picker dialog? I'd love to allow opacity selection from there, but I've not found a way to do it. Thanks Link to comment
ApeWare Posted March 19, 2013 Share Posted March 19, 2013 I created an account specifically to thank you, and the others that helped add the color picker code, for this workflow. It by far the most useful workflow I have installed. As a developer, I will use this multiple times a day. Thanks again for your efforts. Tyler Eich 1 Link to comment
pstadler Posted March 19, 2013 Share Posted March 19, 2013 Amazing, thank you! Tyler Eich 1 Link to comment
albertkinng Posted March 19, 2013 Share Posted March 19, 2013 a flower growing in concret. Excellent! Tyler Eich 1 Link to comment
albertkinng Posted March 19, 2013 Share Posted March 19, 2013 click on paste in front most app and it will be SWEET! Link to comment
epogue Posted March 20, 2013 Share Posted March 20, 2013 This is so awesome! Thank you! Tyler Eich 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now