Quartz implements gradients as part of Core Graphics from Mac OS X 10.2 onwards, but it's kind of hard to use at that level. GCGradient provides a much easier way to access the gradient functionality by hiding the tedious Core Graphics stuff and instead making a much more task-oriented interface available.
With GCGradient, you add colours in a sequence - any number are supported - and set the gradient drawing parameters such as the type of fill (radial or linear), the angles and starting points of the gradients, and so forth. Then when you want to fill a particular path with the gradient, you pass it the path in question and the result is rendered in the current view. GCGradients are small, self-contained and lightweight, and support NSObject, NSCoding and NSCopying protocols. Internally colours are NSColor objects, so the full range of effects such as variable opacity, etc, is supported.
GCGradient has been significantly enhanced and improved, and is now part of a complete framework that includes a user interface for creating, editing and sharing gradients (shown). The updated version of GCGradient is fully backward compatible with the old one, but is enhanced to include:
GCGradient is now part of the GradientPanel framework which is available at http://www.gradientpanel.com. The framework also provides a standard user interface for a complete Gradients Panel similar in nature to NSColorPanel, and GCGradientWell, similar to NSColorWell. However these components are not required to use GCGradient itself, but where an application is making heavy use of gradients, the Gradients panel will significantly reduce the developer burden in providing a UI to work with them.
Note that the Demo and Developer SDK linked here is the same one available at gradientpanel.com.
It's always the same - you make what you think is the perfect release then all sorts of bug reports and feature requests come in. We've fixed all of the bugs and added a couple of "must have" features such as the ability to select a gradient well and have it connect to the panel directly, just as NSColorWell does with NSColorPanel. We've also made most of the features accessible via pop-up contextual menus as well as the toolbar, so you can use the panel fully with the toolbar hidden. We also fixed the 10.3 build so that this version really should run on 10.3 without a hitch. See the release notes for full details of what was changed.
Now interacts properly with other NSColorWells in your application - the stops in the gradient control bar will turn off a selected colour well, and vice versa. This avoids the ambiguous situation where the colour panel can end up setting more than one thing.
© 2006-2008 Graham Cox