DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | Class Methods | Protected Attributes | List of all members
DKGradient Class Reference

A DKGradient encapsulates gradient/shading drawing. More...

Inheritance diagram for DKGradient:
Inheritance graph
[legend]

Instance Methods

(DKColorStop *) - addColor:at:
 
(void) - addColorStop:
 
(CGFloat- angle
 Returns the gradient's current angle in radians. More...
 
(CGFloat- angleInDegrees
 Returns the gradient's current angle in degrees. More...
 
(NSColor *) - colorAtValue:
 Returns the computed Color for the gradient ramp expressed as a value from 0 to 1.0. More...
 
(NSArray *) - colorStops
 Returns the list of Color stops in the gradient. More...
 
(void) - convertOldKey:
 
(void) - convertOldKeys
 
(NSUInteger- countOfColorStops
 Returns the number of Color stops in the gradient. More...
 
(void) - fillContext:startingAtPoint:startRadius:endingAtPoint:endRadius:
 
(void) - fillPath:
 Fills the path using the gradient. More...
 
(void) - fillPath:centreOffset:
 Fills the path using the gradient. More...
 
(void) - fillPath:startingAtPoint:startRadius:endingAtPoint:endRadius:
 
(void) - fillRect:
 
(DKGradientBlending) - gradientBlending
 
(DKGradient *) - gradientByColorizingWithColor:
 Creates a copy of the gradient but colorizies it by substituting the hue from <color> More...
 
(DKGradientInterpolation) - gradientInterpolation
 Returns the interpolation algorithm for the gradient. More...
 
(DKGradientType) - gradientType
 
(DKGradient *) - gradientWithAlpha:
 Creates a copy of the gradient but sets the alpha vealue of all stop colours to <alpha> More...
 
(BOOL- hasRadialSettings
 
(void) - insertObject:inColorStopsAtIndex:
 
(NSPoint) - mapPoint:fromRect:
 
(NSPoint) - mapPoint:toRect:
 
(DKColorStop *) - objectInColorStopsAtIndex:
 Returns the the indexed Color stop. More...
 
(NSPoint) - radialEndingPoint
 
(CGFloat- radialEndingRadius
 
(NSPoint) - radialStartingPoint
 
(CGFloat- radialStartingRadius
 
(void) - removeAllColors
 Removes all Colors from the list of Colors. More...
 
(void) - removeColorStop:
 Removes a Color stop from the list of Colors. More...
 
(void) - removeLastColor
 Removes the last Color from he list of Colors. More...
 
(void) - removeObjectFromColorStopsAtIndex:
 
(void) - reverseColorStops
 Reverses the order of all the Color stops so "inverting" the gradient. More...
 
(void) - setAngle:
 Sets the gradient's current angle in radians. More...
 
(void) - setAngleInDegrees:
 Sets the angle of the gradient to the given angle. More...
 
(void) - setAngleWithoutNotifying:
 
(void) - setColorStops:
 Sets the list of Color stops in the gradient. More...
 
(void) - setGradientBlending:
 
(void) - setGradientInterpolation:
 
(void) - setGradientType:
 Sets the gradient's basic type. More...
 
(void) - setRadialEndingPoint:
 
(void) - setRadialEndingRadius:
 
(void) - setRadialStartingPoint:
 
(void) - setRadialStartingRadius:
 
(void) - setUpExtensionData
 
(void) - sortColorStops
 Sorts the Color stops into position order. More...
 
(NSImage *) - standardSwatchImage
 
(NSImage *) - swatchImageWithSize:withBorder:
 Returns an image of the current gradient for use in a UI, etc. More...
 
- Instance Methods inherited from GCObservableObject
(NSString *) - actionNameForKeyPath:
 
(NSString *) - actionNameForKeyPath:changeKind:
 
(NSArray *) - oldArrayValueForKeyPath:
 
(void) - registerActionNames
 
(void) - sendInitialValuesForAllPropertiesToObserver:context:
 
(void) - setActionName:forKeyPath:
 
(BOOL- setUpKVOForObserver:
 
(void) - setUpObservables:forObserver:
 
(BOOL- tearDownKVOForObserver:
 
(void) - tearDownObservables:forObserver:
 
- Instance Methods inherited from NSObject
(NSString *) - address
 
(DKStyleRegistry *) - applicationWillReturnStyleRegistry
 
(BOOL- canBeUsedWithSelectionTool
 
(id- categoryManager:shouldReplaceObject:withObject:
 
(Class- classForCoder
 
(NSColor *) - colorValue
 
(NSColor *) - colourValue
 
(id- copy
 
(void) - dealloc
 
(id- deepCopy
 
(NSDictionary *) - dimensionValuesForArrowStroke:
 
(CGFloat- drawing:convertDistanceToExternalCoordinates:
 
(NSPoint) - drawing:convertLocationToExternalCoordinates:
 
(void) - drawing:didDrawRect:inView:
 
(void) - drawing:willDrawRect:inView:
 
(NSString *) - drawing:willReturnAbbreviationForUnit:
 
(NSString *) - drawing:willReturnFormattedCoordinateForDistance:
 
(CGFloat- drawingWillReturnUnitToPointsConversonFactor:
 
(void) - finalize
 
(NSString *) - hexString
 
(void) - hotspot:didEndTrackingWithEvent:inView:
 
(void) - hotspot:isTrackingWithEvent:inView:
 
(void) - hotspot:willBeginTrackingWithEvent:inView:
 
(NSData *) - imageData
 
(NSImage *) - imageResourceNamed:
 
(id- init
 
(id- initWithExpression:
 
(id- instantiateObjectWithShortName:parameters:
 
(BOOL- isLiteralValue
 
(void) - layoutManager:willPlaceGlyphAtIndex:atLocation:pathAngle:yOffset:
 
(void) - menuItem:wasAddedForObject:inCategory:
 
(BOOL- moveObjectTo:position:slope:userInfo:
 
(id- mutableCopy
 
(void) - oneShotComplete
 
(void) - oneShotHasReached:
 
(void) - oneShotWillBegin
 
(void) - path:elementIndex:type:points:subPathIndex:subPathClosed:contextInfo:
 
(id- placeLinkFromPoint:toPoint:onPath:linkNumber:userInfo:
 
(id- placeObjectAtPoint:onPath:position:slope:userInfo:
 
(NSPoint) - point
 
(NSPoint) - pointForTextLayout
 
(DKStyle *) - registry:shouldReplaceStyle:withStyle:
 
(NSBezierPath *) - renderer:willRenderPath:
 
(void) - routeFinder:progressHasReached:
 
(void) - setValue:forNumericParameter:
 
(NSString *) - stringValue
 
(CGFloat- taperFactorAtDistance:onPath:ofLength:
 
(void) - toolDidPerformUndoableAction:
 
(void) - toolWillPerformUndoableAction:
 
(NSURL *) - url
 
- Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Instance Methods inherited from <NSKeyValueBindingCreation>
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - exposedBindings
 
(NSDictionary *) - infoForBinding:
 
(NSArray *) - optionDescriptionsForBinding:
 
(void) - unbind:
 
(Class- valueClassForBinding:
 
- Instance Methods inherited from <NSCoding>
(void) - encodeWithCoder:
 
(id- initWithCoder:
 
- Instance Methods inherited from <NSCopying>
(id- copyWithZone:
 

Class Methods

(DKGradient *) + aquaNormalGradient
 
(DKGradient *) + aquaPressedGradient
 
(DKGradient *) + aquaSelectedGradient
 
(DKGradient *) + defaultGradient
 Returns an instance of the default gradient (simple linear black to white) More...
 
(void) + drawShinyGradientInRect:withColour:
 
(DKGradient *) + gradientWithStartingColor:endingColor:
 Returns a linear gradient from Color c1 to c2. More...
 
(DKGradient *) + gradientWithStartingColor:endingColor:type:angle:
 Returns a gradient from Color c1 to c2 with given type and angle. More...
 
(DKGradient *) + sourceListSelectedGradient
 
(DKGradient *) + sourceListUnselectedGradient
 
(DKGradient *) + unifiedDarkGradient
 
(DKGradient *) + unifiedNormalGradient
 
(DKGradient *) + unifiedPressedGradient
 
(DKGradient *) + unifiedSelectedGradient
 
- Class Methods inherited from GCObservableObject
(NSString *) + actionNameForKeyPath:objClass:
 
(NSArray *) + observableKeyPaths
 
(void) + registerActionName:forKeyPath:objClass:
 
- Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 

Protected Attributes

DKGradientBlending m_blending
 
CGFunctionRef m_cbfunc
 
NSMutableArraym_colorStops
 
id m_extensionData
 
CGFloat m_gradAngle
 
DKGradientType m_gradType
 
DKGradientInterpolation m_interp
 

Detailed Description

A DKGradient encapsulates gradient/shading drawing.

Method Documentation

- (DKColorStop*) addColor: (NSColor *)  Color
at: (CGFloat pos 
- (void) addColorStop: (DKColorStop *)  stop
- (CGFloat) angle

Returns the gradient's current angle in radians.

Returns
angle expressed in radians
- (CGFloat) angleInDegrees

Returns the gradient's current angle in degrees.

Returns
angle expressed in degrees
+ (DKGradient*) aquaNormalGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) aquaPressedGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) aquaSelectedGradient

Provided by category DKGradient(UISupport).

- (NSColor*) colorAtValue: (CGFloat val

Returns the computed Color for the gradient ramp expressed as a value from 0 to 1.0.

While intended for internal use, this function can be called at any time if you wish the private version here is called internally. It does fewer checks and returns raw component values for performance. do not use from external code.

Parameters
valthe proportion of the gradient ramp from start (0) to finish (1.0)
Returns
the Color corresponding to that positionReturns the Color associated with this stop
a Color value
- (NSArray*) colorStops

Returns the list of Color stops in the gradient.

A gradient needs a minimum of two Colors to be a gradient, but will function with one.

Returns
the array of DKColorStop (color + position) objects in the gradient
- (void) convertOldKey: (NSString *)  key

Provided by category DKGradient(DKGradientExtensions).

- (void) convertOldKeys

Provided by category DKGradient(DKGradientExtensions).

- (NSUInteger) countOfColorStops

Returns the number of Color stops in the gradient.

This also makes the stops array KVC compliant

Returns
an integer, the number of Colors used to compute the gradient
+ (DKGradient*) defaultGradient

Returns an instance of the default gradient (simple linear black to white)

Returns
autoreleased default gradient object
+ (void) drawShinyGradientInRect: (NSRect aRect
withColour: (NSColor *)  colour 

Provided by category DKGradient(UISupport).

- (void) fillContext: (CGContextRef context
startingAtPoint: (NSPoint)  sp
startRadius: (CGFloat sr
endingAtPoint: (NSPoint)  ep
endRadius: (CGFloat er 
- (void) fillPath: (NSBezierPath *)  path

Fills the path using the gradient.

The fill will proceed as for a standard fill. A gradient that needs a starting point will assume the centre of the path's bounds as that point when using this method.

Parameters
paththe bezier path to fill.
- (void) fillPath: (NSBezierPath *)  path
centreOffset: (NSPoint)  co 

Fills the path using the gradient.

Parameters
paththe bezier path to fill
codisplacement from the centre for the start of a radial fill
- (void) fillPath: (NSBezierPath *)  path
startingAtPoint: (NSPoint)  sp
startRadius: (CGFloat sr
endingAtPoint: (NSPoint)  ep
endRadius: (CGFloat er 
- (void) fillRect: (NSRect rect
- (DKGradientBlending) gradientBlending
- (DKGradient*) gradientByColorizingWithColor: (NSColor *)  color

Creates a copy of the gradient but colorizies it by substituting the hue from <color>

Parameters
colordonates its hue
Returns
a new gradient, a copy of the receiver in every way except colourized by <color>
- (DKGradientInterpolation) gradientInterpolation

Returns the interpolation algorithm for the gradient.

Returns
the current interpolation
- (DKGradientType) gradientType
- (DKGradient*) gradientWithAlpha: (CGFloat alpha

Creates a copy of the gradient but sets the alpha vealue of all stop colours to <alpha>

Parameters
alphathe desired alpha
Returns
a new gradient, a copy of the receiver with requested alpha
+ (DKGradient*) gradientWithStartingColor: (NSColor *)  c1
endingColor: (NSColor *)  c2 

Returns a linear gradient from Color c1 to c2.

Gradient is linear and draws left to right c1 –> c2

Parameters
c1the starting Color
c2the ending Color
Returns
gradient object
+ (DKGradient*) gradientWithStartingColor: (NSColor *)  c1
endingColor: (NSColor *)  c2
type: (NSInteger gt
angle: (CGFloat degrees 

Returns a gradient from Color c1 to c2 with given type and angle.

Parameters
c1the starting Color
c2the ending Color
typethe gradient's type (linear or radial, etc)
degreesangle in degrees
Returns
gradient object
- (BOOL) hasRadialSettings

Provided by category DKGradient(DKGradientExtensions).

- (void) insertObject: (DKColorStop *)  stop
inColorStopsAtIndex: (NSUInteger ix 
- (NSPoint) mapPoint: (NSPoint)  p
fromRect: (NSRect rect 

Provided by category DKGradient(DKGradientExtensions).

- (NSPoint) mapPoint: (NSPoint)  p
toRect: (NSRect rect 

Provided by category DKGradient(DKGradientExtensions).

- (DKColorStop*) objectInColorStopsAtIndex: (NSUInteger ix

Returns the the indexed Color stop.

This also makes the stops array KVC compliant

Parameters
ixindex number of the stop
Returns
a Color stop
- (NSPoint) radialEndingPoint

Provided by category DKGradient(DKGradientExtensions).

- (CGFloat) radialEndingRadius

Provided by category DKGradient(DKGradientExtensions).

- (NSPoint) radialStartingPoint

Provided by category DKGradient(DKGradientExtensions).

- (CGFloat) radialStartingRadius

Provided by category DKGradient(DKGradientExtensions).

- (void) removeAllColors

Removes all Colors from the list of Colors.

- (void) removeColorStop: (DKColorStop *)  stop

Removes a Color stop from the list of Colors.

Parameters
stopthe stop to remove
- (void) removeLastColor

Removes the last Color from he list of Colors.

- (void) removeObjectFromColorStopsAtIndex: (NSUInteger ix
- (void) reverseColorStops

Reverses the order of all the Color stops so "inverting" the gradient.

Stop positions are changed, but Colors are not touched

- (void) setAngle: (CGFloat ang

Sets the gradient's current angle in radians.

Parameters
angthe desired angle in radians
- (void) setAngleInDegrees: (CGFloat degrees

Sets the angle of the gradient to the given angle.

Parameters
degreesthe desired angle expressed in degrees
- (void) setAngleWithoutNotifying: (CGFloat ang
- (void) setColorStops: (NSArray *)  stops

Sets the list of Color stops in the gradient.

A gradient needs a minimum of two Colors to be a gradient, but will function with one.

Parameters
stopsan array of DKColorStop objects
- (void) setGradientBlending: (DKGradientBlending)  bt
- (void) setGradientInterpolation: (DKGradientInterpolation)  intrp
- (void) setGradientType: (DKGradientType)  gt

Sets the gradient's basic type.

Valid types are: kDKGradientTypeLinear and kDKGradientTypeRadial

Parameters
gtthe type
- (void) setRadialEndingPoint: (NSPoint)  p

Provided by category DKGradient(DKGradientExtensions).

- (void) setRadialEndingRadius: (CGFloat rad

Provided by category DKGradient(DKGradientExtensions).

- (void) setRadialStartingPoint: (NSPoint)  p

Provided by category DKGradient(DKGradientExtensions).

- (void) setRadialStartingRadius: (CGFloat rad

Provided by category DKGradient(DKGradientExtensions).

- (void) setUpExtensionData

Provided by category DKGradient(DKGradientExtensions).

- (void) sortColorStops

Sorts the Color stops into position order.

Stops are sorted in place

+ (DKGradient*) sourceListSelectedGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) sourceListUnselectedGradient

Provided by category DKGradient(UISupport).

- (NSImage*) standardSwatchImage
- (NSImage*) swatchImageWithSize: (NSSize)  size
withBorder: (BOOL showBorder 

Returns an image of the current gradient for use in a UI, etc.

Parameters
sizethe desired image size
showBorderYES to draw a border around the image, NO for no border
Returns
an NSIMage containing the current gradient
+ (DKGradient*) unifiedDarkGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) unifiedNormalGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) unifiedPressedGradient

Provided by category DKGradient(UISupport).

+ (DKGradient*) unifiedSelectedGradient

Provided by category DKGradient(UISupport).

Member Data Documentation

- (DKGradientBlending) m_blending
protected
- (CGFunctionRef) m_cbfunc
protected
- (NSMutableArray*) m_colorStops
protected
- (id) m_extensionData
protected
- (CGFloat) m_gradAngle
protected
- (DKGradientType) m_gradType
protected
- (DKGradientInterpolation) m_interp
protected