|
ColorByColorPicker
# Introduction to ColorBy.ColorPicker 2007 © Weizhong Yang (a.k.a zonble), all rights reserved. IntroductionColorBy.colorPicker is a system-wide color picker for Cocoa developers. If you need to create an NSColor object in your Objective-C project, you can use this small utility to help you generate the source code with NSColor class methods and the values of a color by clicking on the color picker. Current VersionVersion 0.1 RequirementMac OS X 10.4 Tiger or above, including Mac OS X 10.5 Leopard. It's a universal binary, so it can run on both PowerPc and Intel Macs. LocalizationsThis utility is localized in:
Installation
UsageBasicSometimes I think that Apple should include this function in their developer tools: to create an NSColor object by easily clicking on the color picker. So, I wrote this small utility. At first, you can pick a color from any other color pickers, such as the color wheel or the color scrollers. When a color is selected, you may switch to the colorBy.colorPicker panel, you will see the generated codes displayed in the text areas. The colorBy.colorPicker panel offers three text areas, each of them generates the code of a color in the HSB (Hue, Saturation and Brightness) model, the RGB (Red, Green and Blue) model and the CMYK (Cyan, Magenta, Yellow and Black) model. Then, you can copy the generated code by clicking on the "Copy" button in the right side, or drag the code into your favorite text editors. Clicking on the text area, the dragging will begin immediately. MethodsColorBy.colorPicker uses the class methods of NSColor class, including:
For instance, when you click on a orange color, it might generate code as following: [NSColor colorWithDeviceHue:0.08 saturation:1.00 brightness:1.00 alpha:1.00] You can just go on completing your code such as: NSColor *aColor = [NSColor colorWithDeviceHue:0.08 saturation:1.00 brightness:1.00 alpha:1.00]; Calibrated color or device colorYou can choose to generate the codes in HSB and RGB model by using the calibrated color space or the device. When you select to use calibrated color, it will generate code with colorWithCalibratedHue:saturation:brightness:alpha: and colorWithCalibratedRed:green:blue:alpha:, otherwise, it will use colorWithDeviceHue:saturation:brightness:alpha: and colorWithDeviceRed:green:blue:alpha: . Check the official document by Apple for detail: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSColor_Class/Reference/Reference.html NotePure black and pure whiteColorBy.colorPicker will ignores the colors in NSDeviceWhiteColorSpace , NSCalibratedWhiteColorSpace, NSDeviceBlackColorSpace, or NSCalibratedBlackColorSpace; It will automatically convert the colors into RGB color space. if the color that you want to use is pure white or pure black, just insert [NSColor whiteColor] or [NSColor blackColor]. Xcode 3 and LeopardThe color picker bundle of version 0.1 was built with 10.4 universal SDK, it runs with most applications on Leopard, but it will not appear in Xcode 3. I have no idea about the behaviors of Xcode 3, it seem that Xcode 3 can use color pickers complied with 10.5 SDK, but I am not quite sure. I complied another one with the 10.5 SDK, if you are now using Leopard, you might consider download this version: http://zonble.googlecode.com/files/colorBy.colorPicker.Leopard.0.1.zip
Enjoy it! |
Sign in to add a comment
The zip file provided doesn't open to create a .colorpicker file. It creates a folder. Maybe an application bundle bit isn't set...
Well, a colorPicker is indeed a folder, However, I think it should work while placing this folder into /Library/ColorPickers?/