Akhil K Nambiar
Akhil K Nambiar

Reputation: 3975

make a NSGradient from a given NSColor

I have a function that paints a particular area with the NSColor that is passed to it. To give it a sort of 3D look I need to paint it with a gradient of the given color. Suppose NSColor is blueColor then the area should be painted with something like lightBlue to blueColor or something as such so that I can get a slight gradient effect.

So my question is how can I create NSColor which is lighter than the NSColor that is passed to the function.

Upvotes: 0

Views: 214

Answers (1)

Dmitry
Dmitry

Reputation: 7340

Look at the NSColor Class Reference "Changing the Color" section. There are several methods to make a new color form existing one:

– blendedColorWithFraction:ofColor:
– colorWithAlphaComponent:
– highlightWithLevel:
– shadowWithLevel:

Also you can create a new color with RGB components calculated from your existing color (or HSB components) with

+ colorWithCalibratedHue:saturation:brightness:alpha:
+ colorWithCalibratedRed:green:blue:alpha:

Upvotes: 1

Related Questions