Core Plot (macOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTGradient Class Reference

Draws color gradient fills. More...

#import <CPTGradient.h>

+ Inheritance diagram for CPTGradient:
+ Collaboration diagram for CPTGradient:

Public Class Methods

Factory Methods
(nonnull instancetype) + gradientWithBeginningColor:endingColor:
 Creates and returns a new CPTGradient instance initialized with an axial linear gradient between two given colors. More...
 
(nonnull instancetype) + gradientWithBeginningColor:endingColor:beginningPosition:endingPosition:
 Creates and returns a new CPTGradient instance initialized with an axial linear gradient between two given colors, at two given normalized positions. More...
 
(nonnull instancetype) + aquaSelectedGradient
 Creates and returns a new CPTGradient instance initialized with the Aqua selected gradient. More...
 
(nonnull instancetype) + aquaNormalGradient
 Creates and returns a new CPTGradient instance initialized with the Aqua normal gradient. More...
 
(nonnull instancetype) + aquaPressedGradient
 Creates and returns a new CPTGradient instance initialized with the Aqua pressed gradient. More...
 
(nonnull instancetype) + unifiedSelectedGradient
 Creates and returns a new CPTGradient instance initialized with the unified selected gradient. More...
 
(nonnull instancetype) + unifiedNormalGradient
 Creates and returns a new CPTGradient instance initialized with the unified normal gradient. More...
 
(nonnull instancetype) + unifiedPressedGradient
 Creates and returns a new CPTGradient instance initialized with the unified pressed gradient. More...
 
(nonnull instancetype) + unifiedDarkGradient
 Creates and returns a new CPTGradient instance initialized with the unified dark gradient. More...
 
(nonnull instancetype) + sourceListSelectedGradient
 Creates and returns a new CPTGradient instance initialized with the source list selected gradient. More...
 
(nonnull instancetype) + sourceListUnselectedGradient
 Creates and returns a new CPTGradient instance initialized with the source list unselected gradient. More...
 
(nonnull instancetype) + rainbowGradient
 Creates and returns a new CPTGradient instance initialized with a rainbow gradient. More...
 
(nonnull instancetype) + hydrogenSpectrumGradient
 Creates and returns a new CPTGradient instance initialized with a hydrogen spectrum gradient. More...
 
- Public Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Public Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 
- Public Class Methods inherited from <NSSecureCoding>
(BOOL+ supportsSecureCoding:
 

Public Instance Methods

Modification
(nonnull CPTGradient *) - gradientWithAlphaComponent:
 Copies the current gradient and sets a new alpha value. More...
 
(nonnull CPTGradient *) - gradientWithBlendingMode:
 Copies the current gradient and sets a new blending mode. More...
 
(nonnull CPTGradient *) - addColorStop:atPosition:
 Copies the current gradient and adds a color stop. More...
 
(nonnull CPTGradient *) - removeColorStopAtIndex:
 Copies the current gradient and removes the color stop at idx from the list of color stops. More...
 
(nonnull CPTGradient *) - removeColorStopAtPosition:
 Copies the current gradient and removes the color stop at position from the list of color stops. More...
 
Information
(nullable CGColorRef- newColorStopAtIndex:
 Gets the color at color stop idx from the list of color stops. More...
 
(nonnull CGColorRef- newColorAtPosition:
 Gets the color at an arbitrary position in the gradient. More...
 
Drawing
(void) - drawSwatchInRect:inContext:
 Draws the gradient into the given graphics context inside the provided rectangle. More...
 
(void) - fillRect:inContext:
 Draws the gradient into the given graphics context inside the provided rectangle. More...
 
(void) - fillPathInContext:
 Draws the gradient into the given graphics context clipped to the current drawing path. More...
 
Initialization
(nonnull instancetype) - init [implementation]
 Initializes a newly allocated CPTGradient object. More...
 
Comparison
(BOOL- isEqual: [implementation]
 Returns a boolean value that indicates whether the received is equal to the given object. Gradients are equal if they have the same blendingMode, angle, gradientType, and gradient colors at the same positions. More...
 
- Public Instance Methods inherited from NSObject
(Class- classForCoder
 
(id- copy
 
(void) - dealloc
 
(void) - finalize
 
(id- init
 
(id- mutableCopy
 
- Public Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Public Instance Methods inherited from <NSKeyValueBindingCreation>
(NSArray *) - exposedBindings
 
(Class- valueClassForBinding:
 
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - optionDescriptionsForBinding:
 
(NSDictionary *) - infoForBinding:
 
(void) - unbind:
 
- Public Instance Methods inherited from <NSCopying>
(id- copyWithZone:
 
- Public Instance Methods inherited from <NSCoding>
(id- initWithCoder:
 
(void) - encodeWithCoder:
 

Properties

BOOL opaque
 If YES, the gradient is completely opaque. More...
 
Gradient Type
CPTGradientBlendingMode blendingMode
 The color blending mode used to create the gradient. More...
 
CPTGradientType gradientType
 The gradient type. More...
 
Axial Gradients
CGFloat angle
 The axis angle of an axial gradient, expressed in degrees and measured counterclockwise from the positive x-axis. More...
 
Radial Gradients
CGPoint startAnchor
 The anchor point for starting point of a radial gradient. Defaults to (0.5, 0.5) which centers the gradient on the drawing rectangle. More...
 
CGPoint endAnchor
 The anchor point for ending point of a radial gradient. Defaults to (0.5, 0.5) which centers the gradient on the drawing rectangle. More...
 

Detailed Description

Draws color gradient fills.

Gradients consist of multiple colors blended smoothly from one to the next at specified positions using one of three blending modes. The color positions are defined in a range between zero (0) and one (1). Axial gradients are drawn with color positions increasing from left to right when the angle property is zero (0). Radial gradients are drawn centered in the provided drawing region with position zero (0) in the center and one (1) at the outer edge.

Note
Based on CTGradient (https://blog.oofn.net/2006/01/15/gradients-in-cocoa/). CTGradient is in the public domain (Thanks Chad Weider!).

Method Documentation

◆ addColorStop:atPosition:

- (CPTGradient *) addColorStop: (nonnull CPTColor *)  color
atPosition: (CGFloat position 

Copies the current gradient and adds a color stop.

Adds a color stop with color at position in the list of color stops. If two elements are at the same position then it is added immediately after the one that was there already.

Parameters
colorThe color.
positionThe color stop position (0position1).
Returns
A copy of the current gradient with the new color stop.

◆ aquaNormalGradient

+ (nonnull instancetype) aquaNormalGradient

Creates and returns a new CPTGradient instance initialized with the Aqua normal gradient.

Returns
A new CPTGradient instance initialized with the Aqua normal gradient.

◆ aquaPressedGradient

+ (nonnull instancetype) aquaPressedGradient

Creates and returns a new CPTGradient instance initialized with the Aqua pressed gradient.

Returns
A new CPTGradient instance initialized with the Aqua pressed gradient.

◆ aquaSelectedGradient

+ (nonnull instancetype) aquaSelectedGradient

Creates and returns a new CPTGradient instance initialized with the Aqua selected gradient.

Returns
A new CPTGradient instance initialized with the Aqua selected gradient.

◆ drawSwatchInRect:inContext:

- (void) drawSwatchInRect: (CGRect rect
inContext: (nonnull CGContextRef context 

Draws the gradient into the given graphics context inside the provided rectangle.

Parameters
rectThe rectangle to draw into.
contextThe graphics context to draw into.

◆ fillPathInContext:

- (void) fillPathInContext: (nonnull CGContextRef context

Draws the gradient into the given graphics context clipped to the current drawing path.

Parameters
contextThe graphics context to draw into.

◆ fillRect:inContext:

- (void) fillRect: (CGRect rect
inContext: (nonnull CGContextRef context 

Draws the gradient into the given graphics context inside the provided rectangle.

Parameters
rectThe rectangle to draw into.
contextThe graphics context to draw into.

◆ gradientWithAlphaComponent:

- (CPTGradient *) gradientWithAlphaComponent: (CGFloat alpha

Copies the current gradient and sets a new alpha value.

Parameters
alphaThe alpha component (0alpha1).
Returns
A copy of the current gradient with the new alpha value.

◆ gradientWithBeginningColor:endingColor:

+ (nonnull instancetype) gradientWithBeginningColor: (nonnull CPTColor *)  begin
endingColor: (nonnull CPTColor *)  end 

Creates and returns a new CPTGradient instance initialized with an axial linear gradient between two given colors.

Parameters
beginThe beginning color.
endThe ending color.
Returns
A new CPTGradient instance initialized with an axial linear gradient between the two given colors.

◆ gradientWithBeginningColor:endingColor:beginningPosition:endingPosition:

+ (nonnull instancetype) gradientWithBeginningColor: (nonnull CPTColor *)  begin
endingColor: (nonnull CPTColor *)  end
beginningPosition: (CGFloat beginningPosition
endingPosition: (CGFloat endingPosition 

Creates and returns a new CPTGradient instance initialized with an axial linear gradient between two given colors, at two given normalized positions.

Parameters
beginThe beginning color.
endThe ending color.
beginningPositionThe beginning position (0beginningPosition1).
endingPositionThe ending position (0endingPosition1).
Returns
A new CPTGradient instance initialized with an axial linear gradient between the two given colors, at two given normalized positions.

◆ gradientWithBlendingMode:

- (CPTGradient *) gradientWithBlendingMode: (CPTGradientBlendingMode mode

Copies the current gradient and sets a new blending mode.

Parameters
modeThe blending mode.
Returns
A copy of the current gradient with the new blending mode.

◆ hydrogenSpectrumGradient

+ (nonnull instancetype) hydrogenSpectrumGradient

Creates and returns a new CPTGradient instance initialized with a hydrogen spectrum gradient.

Returns
A new CPTGradient instance initialized with a hydrogen spectrum gradient.

◆ init

- (nonnull instancetype) init
implementation

Initializes a newly allocated CPTGradient object.

The initialized object will have the following properties:

Returns
The initialized object.

◆ isEqual:

- (BOOL) isEqual: (nullable id object
implementation

Returns a boolean value that indicates whether the received is equal to the given object. Gradients are equal if they have the same blendingMode, angle, gradientType, and gradient colors at the same positions.

Parameters
objectThe object to be compared with the receiver.
Returns
YES if object is equal to the receiver, NO otherwise.

◆ newColorAtPosition:

- (CGColorRef) newColorAtPosition: (CGFloat position

Gets the color at an arbitrary position in the gradient.

Parameters
positionThe color stop position (0position1).
Returns
The color at position in gradient.

◆ newColorStopAtIndex:

- (CGColorRef) newColorStopAtIndex: (NSUInteger idx

Gets the color at color stop idx from the list of color stops.

Parameters
idxThe color stop index.
Returns
The color at color stop idx.

◆ rainbowGradient

+ (nonnull instancetype) rainbowGradient

Creates and returns a new CPTGradient instance initialized with a rainbow gradient.

Returns
A new CPTGradient instance initialized with a rainbow gradient.

◆ removeColorStopAtIndex:

- (CPTGradient *) removeColorStopAtIndex: (NSUInteger idx

Copies the current gradient and removes the color stop at idx from the list of color stops.

Parameters
idxThe color stop index.
Returns
A copy of the current gradient with the color stop removed.

◆ removeColorStopAtPosition:

- (CPTGradient *) removeColorStopAtPosition: (CGFloat position

Copies the current gradient and removes the color stop at position from the list of color stops.

Parameters
positionThe color stop position (0position1).
Returns
A copy of the current gradient with the color stop removed.

◆ sourceListSelectedGradient

+ (nonnull instancetype) sourceListSelectedGradient

Creates and returns a new CPTGradient instance initialized with the source list selected gradient.

Returns
A new CPTGradient instance initialized with the source list selected gradient.

◆ sourceListUnselectedGradient

+ (nonnull instancetype) sourceListUnselectedGradient

Creates and returns a new CPTGradient instance initialized with the source list unselected gradient.

Returns
A new CPTGradient instance initialized with the source list unselected gradient.

◆ unifiedDarkGradient

+ (nonnull instancetype) unifiedDarkGradient

Creates and returns a new CPTGradient instance initialized with the unified dark gradient.

Returns
A new CPTGradient instance initialized with the unified dark gradient.

◆ unifiedNormalGradient

+ (nonnull instancetype) unifiedNormalGradient

Creates and returns a new CPTGradient instance initialized with the unified normal gradient.

Returns
A new CPTGradient instance initialized with the unified normal gradient.

◆ unifiedPressedGradient

+ (nonnull instancetype) unifiedPressedGradient

Creates and returns a new CPTGradient instance initialized with the unified pressed gradient.

Returns
A new CPTGradient instance initialized with the unified pressed gradient.

◆ unifiedSelectedGradient

+ (nonnull instancetype) unifiedSelectedGradient

Creates and returns a new CPTGradient instance initialized with the unified selected gradient.

Returns
A new CPTGradient instance initialized with the unified selected gradient.

Property Documentation

◆ angle

- (CGFloat) angle
readwritenonatomicassign

The axis angle of an axial gradient, expressed in degrees and measured counterclockwise from the positive x-axis.

◆ blendingMode

- (CPTGradientBlendingMode) blendingMode
readnonatomicassign

The color blending mode used to create the gradient.

◆ endAnchor

- (CGPoint) endAnchor
readwritenonatomicassign

The anchor point for ending point of a radial gradient. Defaults to (0.5, 0.5) which centers the gradient on the drawing rectangle.

◆ gradientType

- (CPTGradientType) gradientType
readwritenonatomicassign

The gradient type.

◆ opaque

- (BOOL) opaque
readnonatomicassign

If YES, the gradient is completely opaque.

◆ startAnchor

- (CGPoint) startAnchor
readwritenonatomicassign

The anchor point for starting point of a radial gradient. Defaults to (0.5, 0.5) which centers the gradient on the drawing rectangle.


The documentation for this class was generated from the following files: