Core Plot (iOS and tvOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTGradient.h
Go to the documentation of this file.
1 // Based on CTGradient (https://blog.oofn.net/2006/01/15/gradients-in-cocoa/)
2 // CTGradient is in public domain (Thanks Chad Weider!)
3 
5 
6 #import "CPTDefinitions.h"
7 
11 typedef struct _CPTGradientElement {
14 
15  struct _CPTGradientElement *__nullable nextElement;
16 }
18 
22 typedef NS_ENUM (NSInteger, CPTGradientBlendingMode) {
26 };
27 
31 typedef NS_ENUM (NSInteger, CPTGradientType) {
34 };
35 
36 @class CPTColorSpace;
37 @class CPTColor;
38 
40 
41 @property (nonatomic, readonly, getter = isOpaque) BOOL opaque;
42 
45 @property (nonatomic, readonly) CPTGradientBlendingMode blendingMode;
46 @property (nonatomic, readwrite, assign) CPTGradientType gradientType;
48 
51 @property (nonatomic, readwrite, assign) CGFloat angle;
53 
56 @property (nonatomic, readwrite, assign) CGPoint startAnchor;
57 @property (nonatomic, readwrite, assign) CGPoint endAnchor;
59 
62 +(nonnull instancetype)gradientWithBeginningColor:(nonnull CPTColor *)begin endingColor:(nonnull CPTColor *)end;
63 +(nonnull instancetype)gradientWithBeginningColor:(nonnull CPTColor *)begin endingColor:(nonnull CPTColor *)end beginningPosition:(CGFloat)beginningPosition endingPosition:(CGFloat)endingPosition;
64 
65 +(nonnull instancetype)aquaSelectedGradient;
66 +(nonnull instancetype)aquaNormalGradient;
67 +(nonnull instancetype)aquaPressedGradient;
68 
69 +(nonnull instancetype)unifiedSelectedGradient;
70 +(nonnull instancetype)unifiedNormalGradient;
71 +(nonnull instancetype)unifiedPressedGradient;
72 +(nonnull instancetype)unifiedDarkGradient;
73 
74 +(nonnull instancetype)sourceListSelectedGradient;
75 +(nonnull instancetype)sourceListUnselectedGradient;
76 
77 +(nonnull instancetype)rainbowGradient;
78 +(nonnull instancetype)hydrogenSpectrumGradient;
80 
83 -(nonnull CPTGradient *)gradientWithAlphaComponent:(CGFloat)alpha;
84 -(nonnull CPTGradient *)gradientWithBlendingMode:(CPTGradientBlendingMode)mode;
85 
86 -(nonnull CPTGradient *)addColorStop:(nonnull CPTColor *)color atPosition:(CGFloat)position; // positions given relative to [0,1]
87 -(nonnull CPTGradient *)removeColorStopAtIndex:(NSUInteger)idx;
88 -(nonnull CPTGradient *)removeColorStopAtPosition:(CGFloat)position;
90 
93 -(nullable CGColorRef)newColorStopAtIndex:(NSUInteger)idx CF_RETURNS_RETAINED;
94 -(nonnull CGColorRef)newColorAtPosition:(CGFloat)position CF_RETURNS_RETAINED;
96 
99 -(void)drawSwatchInRect:(CGRect)rect inContext:(nonnull CGContextRef)context;
100 -(void)fillRect:(CGRect)rect inContext:(nonnull CGContextRef)context;
101 -(void)fillPathInContext:(nonnull CGContextRef)context;
103 
104 @end
CPTGradientElement::nextElement
struct _CPTGradientElement *__nullable nextElement
Pointer to the next CPTGradientElement in the list (last element == NULL)
Definition: CPTGradient.h:15
CGColorRef
typedef CGColorRef
CPTGradientElement::position
CGFloat position
Gradient position (0 ≤ position ≤ 1)
Definition: CPTGradient.h:13
+[CPTGradient unifiedDarkGradient]
nonnull instancetype unifiedDarkGradient()
Creates and returns a new CPTGradient instance initialized with the unified dark gradient.
Definition: CPTGradient.m:492
NSObject
+[CPTGradient sourceListSelectedGradient]
nonnull instancetype sourceListSelectedGradient()
Creates and returns a new CPTGradient instance initialized with the source list selected gradient.
Definition: CPTGradient.m:517
+[CPTGradient aquaPressedGradient]
nonnull instancetype aquaPressedGradient()
Creates and returns a new CPTGradient instance initialized with the Aqua pressed gradient.
Definition: CPTGradient.m:378
+[CPTGradient unifiedSelectedGradient]
nonnull instancetype unifiedSelectedGradient()
Creates and returns a new CPTGradient instance initialized with the unified selected gradient.
Definition: CPTGradient.m:417
CPTGradientType
CPTGradientType
Enumeration of gradient types.
Definition: CPTGradient.h:31
CPTLinearBlendingMode
@ CPTLinearBlendingMode
Linear blending mode.
Definition: CPTGradient.h:23
NSUInteger
typedef NSUInteger
+[CPTGradient aquaNormalGradient]
nonnull instancetype aquaNormalGradient()
Creates and returns a new CPTGradient instance initialized with the Aqua normal gradient.
Definition: CPTGradient.m:339
CPTGradient::opaque
BOOL opaque
If YES, the gradient is completely opaque.
Definition: CPTGradient.h:41
CPTColor
An immutable color.
Definition: CPTColor.h:3
CPTRGBAColor
RGBA color for gradients.
Definition: CPTDefinitions.h:174
+[CPTGradient rainbowGradient]
nonnull instancetype rainbowGradient()
Creates and returns a new CPTGradient instance initialized with a rainbow gradient.
Definition: CPTGradient.m:575
+[CPTGradient unifiedPressedGradient]
nonnull instancetype unifiedPressedGradient()
Creates and returns a new CPTGradient instance initialized with the unified pressed gradient.
Definition: CPTGradient.m:467
CPTGradientElement
A structure representing one node in a linked list of RGBA colors.
Definition: CPTGradient.h:11
BOOL
typedef BOOL
CGContextRef
typedef CGContextRef
CPTGradient::gradientType
CPTGradientType gradientType
The gradient type.
Definition: CPTGradient.h:46
CPTDefinitions.h
CPTChromaticBlendingMode
@ CPTChromaticBlendingMode
Chromatic blending mode.
Definition: CPTGradient.h:24
CGFloat
typedef CGFloat
CPTInverseChromaticBlendingMode
@ CPTInverseChromaticBlendingMode
Inverse chromatic blending mode.
Definition: CPTGradient.h:25
CPTGradient::startAnchor
CGPoint startAnchor
The anchor point for starting point of a radial gradient. Defaults to (0.5, 0.5) which centers the gr...
Definition: CPTGradient.h:56
+[CPTGradient aquaSelectedGradient]
nonnull instancetype aquaSelectedGradient()
Creates and returns a new CPTGradient instance initialized with the Aqua selected gradient.
Definition: CPTGradient.m:292
+[CPTGradient sourceListUnselectedGradient]
nonnull instancetype sourceListUnselectedGradient()
Creates and returns a new CPTGradient instance initialized with the source list unselected gradient.
Definition: CPTGradient.m:546
CPTGradient
Draws color gradient fills.
Definition: CPTGradient.h:39
CPTGradient::endAnchor
CGPoint endAnchor
The anchor point for ending point of a radial gradient. Defaults to (0.5, 0.5) which centers the grad...
Definition: CPTGradient.h:57
+[CPTGradient hydrogenSpectrumGradient]
nonnull instancetype hydrogenSpectrumGradient()
Creates and returns a new CPTGradient instance initialized with a hydrogen spectrum gradient.
Definition: CPTGradient.m:606
CPTGradient::angle
CGFloat angle
The axis angle of an axial gradient, expressed in degrees and measured counterclockwise from the posi...
Definition: CPTGradient.h:51
CPTGradient::blendingMode
CPTGradientBlendingMode blendingMode
The color blending mode used to create the gradient.
Definition: CPTGradient.h:45
CPTGradientTypeRadial
@ CPTGradientTypeRadial
Radial gradient.
Definition: CPTGradient.h:33
CGRect
typedef CGRect
CPTGradientBlendingMode
CPTGradientBlendingMode
Enumeration of blending modes.
Definition: CPTGradient.h:22
CPTColorSpace
An immutable color space.
Definition: CPTColorSpace.h:1
CPTGradientElement::color
CPTRGBAColor color
Color.
Definition: CPTGradient.h:12
CPTGradientTypeAxial
@ CPTGradientTypeAxial
Axial gradient.
Definition: CPTGradient.h:32
NSSecureCoding-p
+[CPTGradient unifiedNormalGradient]
nonnull instancetype unifiedNormalGradient()
Creates and returns a new CPTGradient instance initialized with the unified normal gradient.
Definition: CPTGradient.m:442