|
| 1 | +// |
| 2 | +// CTGradient.h |
| 3 | +// |
| 4 | +// Created by Chad Weider on 2/14/07. |
| 5 | +// Writtin by Chad Weider. |
| 6 | +// |
| 7 | +// Released into public domain on 4/10/08. |
| 8 | +// |
| 9 | +// Version: 1.8 |
| 10 | + |
| 11 | +#import <Cocoa/Cocoa.h> |
| 12 | + |
| 13 | +typedef struct _CTGradientElement |
| 14 | +{ |
| 15 | + float red, green, blue, alpha; |
| 16 | + float position; |
| 17 | + |
| 18 | + struct _CTGradientElement *nextElement; |
| 19 | +} CTGradientElement; |
| 20 | + |
| 21 | +typedef enum _CTBlendingMode |
| 22 | +{ |
| 23 | + CTLinearBlendingMode, |
| 24 | + CTChromaticBlendingMode, |
| 25 | + CTInverseChromaticBlendingMode |
| 26 | +} CTGradientBlendingMode; |
| 27 | + |
| 28 | + |
| 29 | +@interface CTGradient : NSObject <NSCopying, NSCoding> |
| 30 | +{ |
| 31 | + CTGradientElement* elementList; |
| 32 | + CTGradientBlendingMode blendingMode; |
| 33 | + |
| 34 | + CGFunctionRef gradientFunction; |
| 35 | +} |
| 36 | + |
| 37 | ++ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end; |
| 38 | + |
| 39 | ++ (id)aquaSelectedGradient; |
| 40 | ++ (id)aquaNormalGradient; |
| 41 | ++ (id)aquaPressedGradient; |
| 42 | + |
| 43 | ++ (id)unifiedSelectedGradient; |
| 44 | ++ (id)unifiedNormalGradient; |
| 45 | ++ (id)unifiedPressedGradient; |
| 46 | ++ (id)unifiedDarkGradient; |
| 47 | + |
| 48 | ++ (id)sourceListSelectedGradient; |
| 49 | ++ (id)sourceListUnselectedGradient; |
| 50 | + |
| 51 | ++ (id)rainbowGradient; |
| 52 | ++ (id)hydrogenSpectrumGradient; |
| 53 | + |
| 54 | +- (CTGradient *)gradientWithAlphaComponent:(float)alpha; |
| 55 | + |
| 56 | +- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1] |
| 57 | +- (CTGradient *)removeColorStopAtIndex:(unsigned)index; |
| 58 | +- (CTGradient *)removeColorStopAtPosition:(float)position; |
| 59 | + |
| 60 | +- (CTGradientBlendingMode)blendingMode; |
| 61 | +- (NSColor *)colorStopAtIndex:(unsigned)index; |
| 62 | +- (NSColor *)colorAtPosition:(float)position; |
| 63 | + |
| 64 | + |
| 65 | +- (void)drawSwatchInRect:(NSRect)rect; |
| 66 | +- (void)fillRect:(NSRect)rect angle:(float)angle; //fills rect with axial gradient |
| 67 | +// angle in degrees |
| 68 | +- (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient |
| 69 | +// gradient from center outwards |
| 70 | +- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; |
| 71 | +- (void)radialFillBezierPath:(NSBezierPath *)path; |
| 72 | + |
| 73 | +@end |
0 commit comments