Git Product home page Git Product logo

colorsense-for-xcode's Introduction

ColorSense for Xcode

Overview

ColorSense is an Xcode plugin that makes working with UIColor (and NSColor) more visual.

There are many tools that allow you to insert a UIColor/NSColor from a color picker or by picking a color from the screen. But once you've inserted it, it can be hard to remember which color you're actually looking at in your code because you basically just have a series of numbers.

This is where ColorSense comes in: When you put the caret on one of your colors, it automatically shows the actual color as an overlay, and you can even adjust it on-the-fly with the standard Mac OS X color picker.

The plugin also adds some items to the Edit menu to insert colors and to disable color highlighting temporarily. These menu items have no keyboard shortcuts by default, but you can set them via the system's keyboard preferences (Xcode's own preferences won't show them).

Watch Demo Video (YouTube)

I'm @olemoritz on Twitter.

Flattr this

Installation

Simply build the Xcode project and restart Xcode. The plugin will automatically be installed in ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins. To uninstall, just remove the plugin from there (and restart Xcode).

If you get a "Permission Denied" error while building, please see this issue.

This is tested on OS X 10.8 with Xcode 4.4.1 and 4.5.

Limitations

  • It only works for constant colors, something like [UIColor colorWithWhite:foo * bar + 1 alpha:baz] won't work.

  • Only RGB (colorWithRed:green:blue:alpha:), grayscale (colorWithWhite:alpha:), and named colors (redColor...) are supported at the moment (no HSB or CMYK).

License

Copyright (c) 2012, Ole Zorn
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

colorsense-for-xcode's People

Contributors

brandonroeder avatar neonichu avatar nxsoftware avatar omz avatar romaonthego avatar singro avatar stoneark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorsense-for-xcode's Issues

Feature request: Support for CGColorRef

Not sure how hard that would be.. Prolly not too bad.. An simple category would handle the color translation.. I havent looked under the hood to see how youre parsing / recognizing the code's context, but thats prolly the hardest aspect of it, no?

Provide support for .storyboard and .xib files

A .storyboard or a .xib file can be viewed as XML source code in Xcode. A color definition in Xcode XML looks like this:

<color key="textColor" red="0.93333333330000001" green="0.1764705882" blue="0.16862745100000001" alpha="1" colorSpace="calibratedRGB"/>

It would be great, if ColorSense would at least recognize colors in XML files too. Even better: a menu item for finding and replacing of all occurrences of a color in a storyboard or xib source code.

`-Wconversion` compliant floats

When using this wonderful plugin, code is generated like so:

[UIColor colorWithRed:0.065 green:0.576 blue:0.865 alpha:1.000];

This will cause warnings if -Wconversion is on:

error: implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float') [-Werror,-Wconversion]

It can be fixed with a simple change:

[UIColor colorWithRed:0.065f green:0.576f blue:0.865f alpha:1.000f];

ColorSense should use the later format, with f type specifiers.

xcode 5 GM

I had this working on xcode 5 beta, but now I've installed the GM it doesn't seem to work.
Anyone else?

ColorSense not activating under carat

I was able to install the plugin, and if I start typing a new [UIColor ...] snippet, ColorSense will activate. However, I cannot get the palette to appear for existing UIColor code snippets. I am using OSX 10.8.1 and Xcode 4.4.1

Updated regex for rgb color with ()

eg: [UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:153.0/255 alpha:1.0f];

_rgbaUIColorRegex = [[NSRegularExpression regularExpressionWithPattern:@"(\\[\\s*UIColor\\s+colorWith|\\[\\s*\\[\\s*UIColor\\s+alloc\\]\\s*initWith)Red:\\s*\\(?\\s*([0-9]*\\.?[0-9]*f?)\\s*(\\/\\s*[0-9]*\\.?[0-9]*f?)?\\s*\\)?\\s+green:\\s*\\(?\\s*([0-9]*\\.?[0-9]*f?)\\s*(\\/\\s*[0-9]*\\.?[0-9]*f?)?\\s*\\)?\\s+blue:\\s*\\(?\\s*([0-9]*\\.?[0-9]*f?)\\s*(\\/\\s*[0-9]*\\.?[0-9]*f?)?\\s*\\)?\\s*alpha:\\s*\\(?\\s*([0-9]*\\.?[0-9]*f?)\\s*(\\/\\s*[0-9]*\\.?[0-9]*f?)?\\s*\\)?\\s*]" options:0 error:NULL] retain];

Fix for Xcode 5.1

Hello sir,

Please update your plugin for sprout for Arc and Xcode 5.1.

Thanks.

Can't "activate" ColorSense

Hi,

I just installed ColorSense plugin.
I didn't receive any permissions denied error (and the plugin was successfully copied to ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins), however when I select/write a UIColor, nothing happens.

Is there any service that should be activated?

Thanks,
StaS

Stop working with XCode 5.0

Compiling runs ok but then, after reopening XCode, the plugin does not work with latest XCode 5 (5A1413) on OSX 10.8.5

XCode 7.3 compatibility

Please add required compatibility with XCode 7.3. Right now the plugin crashes IDE on the start.

Disappears after every interaction

Just installed your plugin. Great idea!

Unfortunately, the color palette control disappears after every interaction, making it nigh on impossible to use.

So whenever I open the colorspace dropdown and select a different one, the control disappears and forgets the new selection. Every time I select one of the RGB value fields to change, the control disappears. If I drag one of the RGB sliders, the control disappears... although it seems to make the change in this case.

I'm using Xcode Version 6.2 (6C131e).

Please add support for SKColor

As of recently in the Swift language, UIColor and NSColor are both aliased with 'SKColor' for cross-comaptibility across Macs and iOS devices. Please add support for the SKColor class to use with your awesome tool! (SKColor = SpriteKit Color)

Failed to connect (hostViewController) outlet when loading in Xcode6.2

seams because of deprecated NSTextInput, which should be changed to NSTextInputClient, it wont work in XCode6.2 even if building is successful and passing UUID check worked.

Xcode[...]: Failed to connect (hostViewController) outlet from (NSTextFieldCell) to (IDEQuickHelpCompletionInfoViewController): missing setter or instance variable

Feature suggestion: insert colors in RGB (xxx/255)

Hello,

This plugin is simply awesome. I hope Apple incorporate that into XCode by default.

I have a suggestion that might help when working with designers.

Currently all my UIColor code is formatted like that:

[UIColor colorWithRed:181/255.0 green:24/255.0 blue:7/255.0 alpha:1.00f];

And ColorSense doesn't seem to recognize that by default. Would be good if ColorSense could work with that format and input aswell. This is easier because designers are always sending RGB values.

Thanks!

Not working on Xcode 6.4

Hi,

It was working fine on Xcode 6.3.2 but it's no longer working. Can you please add the UDID so it can work on Xcode 6.4?

Thanks!

Does not work on xcode 7

I have not been able to run this wonderful plugin in xcode 7. It seems like one of the function is deprecated on the OSX 10.10.

The deprecated function is : - (NSRect) firstRectForCharacterRange:(NSRange)theRange

Please help see if you can solve this problem. Thanks in advance!! 😄

Does it support some color macros?

When I coding, I usually define some color macros like this:

#define UIColor4i(r, g, b, a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)/100.0f]
#define UIColor3i(r, g, b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0f]
#define UIColor4f(r, g, b, a) [UIColor colorWithRed:(r) green:(g) blue:(b) alpha:(a)]

and I used the "UIColor3i(255, 255, 255)" to set the color.

But I found that this plugin not supports those defines, so I modify it, and it works ok for those defines.

Could you add some color macros to quickly set colors?

Thank you very much to review.

Support for CIColor

Please add support for CIColor, like
[CIColor colorWithRed:0.5f green:0.5f blue:0.5f].
Thank you.

Need XCode 5.1 support

After upgrade to XCode 5.1 (5B130a). The plugin does not work anymore. I try to reinstall at the same as install in XCode 5 but it does not success.

Color palet dismissed on mouse down

Nice plugin! Only, I find it difficult to select a colour. As soon as I press my mouse button, the colour panel gets dismissed. I actually expected it to stay visible, so I could play with the sliders until I got the colour I wanted.

issues with XCode 5

With XCode 5 beta 2, there is a warning about text encryption each the color palette appears, and OMColorSense isn't available anymore in beta 3 (which suck cause it's such a useful tool :p)

RGB with hexadecimal color

Not Work RGB with hexadecimal color ;

example:[UIColor colorWithRGBHex:0xF5F6F7];

  • (UIColor*) colorWithRGBHex: (UInt32) hex {
    int r = (hex >> 16) & 0xFF;
    int g = (hex >> 8) & 0xFF;
    int b = (hex) & 0xFF;
    return [UIColor colorWithRed: r / 255.0f
    green: g / 255.0f
    blue: b / 255.0f
    alpha: 1.0f];
    }

XCode 4.6.3, Mavericks problem

I'm trying to build source code, but build is stuck at some point. The sam behaviour when I try to install it via Alcatraz XCode package manager

Support for SpriteKit (SKColor)

SpriteKit defines a macro to make it easy to support both OS X and iOS: SKColor. The semantics are the same as NSColor and UIColor.

Permission denied

I got this error when building:

error: couldn't create directory /Users/smd/Library/Application Support/Developer/Shared/Xcode/Plug-ins/OMColorSense.xcplugin/Contents: Permission denied

If you have similar error message, just create Plug-ins directory and chmod 777.

$ sudo mkdir /Users/smd/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/
$ sudo chmod -R 777 /Users/smd/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/

Color picker view is dismissed when editing

Add UIColor to an Objective C file and click to bring up the color picker. While you input a value the color picker view will be dismissed. This bug clearly critically breaks the use of this plug-in .

Spec;
Xcode 7.1
OS: El Capitan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.