1 | // |
---|
2 | // CTGradient.h |
---|
3 | // |
---|
4 | // Created by Chad Weider on 2/14/07. |
---|
5 | // Copyright (c) 2007 Chad Weider. |
---|
6 | // Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> |
---|
7 | // |
---|
8 | // Version: 1.6 |
---|
9 | |
---|
10 | #import <Cocoa/Cocoa.h> |
---|
11 | |
---|
12 | typedef struct _CTGradientElement |
---|
13 | { |
---|
14 | float red, green, blue, alpha; |
---|
15 | float position; |
---|
16 | |
---|
17 | struct _CTGradientElement *nextElement; |
---|
18 | } CTGradientElement; |
---|
19 | |
---|
20 | typedef enum _CTBlendingMode |
---|
21 | { |
---|
22 | CTLinearBlendingMode, |
---|
23 | CTChromaticBlendingMode, |
---|
24 | CTInverseChromaticBlendingMode |
---|
25 | } CTGradientBlendingMode; |
---|
26 | |
---|
27 | |
---|
28 | @interface CTGradient : NSObject <NSCopying, NSCoding> |
---|
29 | { |
---|
30 | CTGradientElement* elementList; |
---|
31 | CTGradientBlendingMode blendingMode; |
---|
32 | |
---|
33 | CGFunctionRef gradientFunction; |
---|
34 | } |
---|
35 | |
---|
36 | + (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end; |
---|
37 | |
---|
38 | - (CTGradient *)gradientWithAlphaComponent:(float)alpha; |
---|
39 | |
---|
40 | - (void)addElement:(CTGradientElement*)newElement; |
---|
41 | |
---|
42 | - (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1] |
---|
43 | - (CTGradient *)removeColorStopAtIndex:(unsigned)index; |
---|
44 | - (CTGradient *)removeColorStopAtPosition:(float)position; |
---|
45 | |
---|
46 | - (CTGradientBlendingMode)blendingMode; |
---|
47 | - (NSColor *)colorStopAtIndex:(unsigned)index; |
---|
48 | - (NSColor *)colorAtPosition:(float)position; |
---|
49 | |
---|
50 | |
---|
51 | - (void)drawSwatchInRect:(NSRect)rect; |
---|
52 | - (void)fillRect:(NSRect)rect angle:(float)angle; //fills rect with axial gradient |
---|
53 | // angle in degrees |
---|
54 | - (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient |
---|
55 | // gradient from center outwards |
---|
56 | - (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; |
---|
57 | - (void)radialFillBezierPath:(NSBezierPath *)path; |
---|
58 | |
---|
59 | @end |
---|