Core Plot (iOS and tvOS)
Cocoa plotting framework for macOS, iOS, and tvOS
|
Draws color gradient fills. More...
#import <CPTGradient.h>
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 <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 <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... | |
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.
CTGradient
(https://blog.oofn.net/2006/01/15/gradients-in-cocoa/). CTGradient
is in the public domain (Thanks Chad Weider!). - (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.
color | The color. |
position | The color stop position (0 ≤ position ≤ 1 ). |
+ (nonnull instancetype) aquaNormalGradient |
Creates and returns a new CPTGradient instance initialized with the Aqua normal gradient.
+ (nonnull instancetype) aquaPressedGradient |
Creates and returns a new CPTGradient instance initialized with the Aqua pressed gradient.
+ (nonnull instancetype) aquaSelectedGradient |
Creates and returns a new CPTGradient instance initialized with the Aqua selected gradient.
- (void) drawSwatchInRect: | (CGRect) | rect | |
inContext: | (nonnull CGContextRef) | context | |
Draws the gradient into the given graphics context inside the provided rectangle.
rect | The rectangle to draw into. |
context | The graphics context to draw into. |
- (void) fillPathInContext: | (nonnull CGContextRef) | context |
Draws the gradient into the given graphics context clipped to the current drawing path.
context | The graphics context to draw into. |
- (void) fillRect: | (CGRect) | rect | |
inContext: | (nonnull CGContextRef) | context | |
Draws the gradient into the given graphics context inside the provided rectangle.
rect | The rectangle to draw into. |
context | The graphics context to draw into. |
- (CPTGradient *) gradientWithAlphaComponent: | (CGFloat) | alpha |
Copies the current gradient and sets a new alpha value.
alpha | The alpha component (0 ≤ alpha ≤ 1 ). |
+ (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.
begin | The beginning color. |
end | The ending color. |
+ (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.
begin | The beginning color. |
end | The ending color. |
beginningPosition | The beginning position (0 ≤ beginningPosition ≤ 1 ). |
endingPosition | The ending position (0 ≤ endingPosition ≤ 1 ). |
- (CPTGradient *) gradientWithBlendingMode: | (CPTGradientBlendingMode) | mode |
Copies the current gradient and sets a new blending mode.
mode | The blending mode. |
+ (nonnull instancetype) hydrogenSpectrumGradient |
Creates and returns a new CPTGradient instance initialized with a hydrogen spectrum gradient.
|
implementation |
Initializes a newly allocated CPTGradient object.
The initialized object will have the following properties:
0.0
0.5
, 0.5
)0.5
, 0.5
)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.
object | The object to be compared with the receiver. |
- (CGColorRef) newColorAtPosition: | (CGFloat) | position |
Gets the color at an arbitrary position in the gradient.
position | The color stop position (0 ≤ position ≤ 1 ). |
position
in gradient. - (CGColorRef) newColorStopAtIndex: | (NSUInteger) | idx |
Gets the color at color stop idx
from the list of color stops.
idx | The color stop index. |
idx
. + (nonnull instancetype) rainbowGradient |
Creates and returns a new CPTGradient instance initialized with a rainbow gradient.
- (CPTGradient *) removeColorStopAtIndex: | (NSUInteger) | idx |
Copies the current gradient and removes the color stop at idx
from the list of color stops.
idx | The color stop index. |
- (CPTGradient *) removeColorStopAtPosition: | (CGFloat) | position |
Copies the current gradient and removes the color stop at position
from the list of color stops.
position | The color stop position (0 ≤ position ≤ 1 ). |
+ (nonnull instancetype) sourceListSelectedGradient |
Creates and returns a new CPTGradient instance initialized with the source list selected gradient.
+ (nonnull instancetype) sourceListUnselectedGradient |
Creates and returns a new CPTGradient instance initialized with the source list unselected gradient.
+ (nonnull instancetype) unifiedDarkGradient |
Creates and returns a new CPTGradient instance initialized with the unified dark gradient.
+ (nonnull instancetype) unifiedNormalGradient |
Creates and returns a new CPTGradient instance initialized with the unified normal gradient.
+ (nonnull instancetype) unifiedPressedGradient |
Creates and returns a new CPTGradient instance initialized with the unified pressed gradient.
+ (nonnull instancetype) unifiedSelectedGradient |
Creates and returns a new CPTGradient instance initialized with the unified selected gradient.
|
readwritenonatomicassign |
The axis angle of an axial gradient, expressed in degrees and measured counterclockwise from the positive x-axis.
|
readnonatomicassign |
The color blending mode used to create the gradient.
|
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.
|
readwritenonatomicassign |
The gradient type.
|
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.