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

This class provides a simple hatching fill for a path. More...

Inheritance diagram for DKHatching:
Inheritance graph
[legend]

Instance Methods

(CGFloat- angle
 The angle of the hatching. More...
 
(CGFloat- angleInDegrees
 The angle of the hatching in degrees. More...
 
(BOOL- angleIsRelativeToObject
 
(void) - calcHatchInRect:
 
(NSColor *) - colour
 
(DKStrokeDash *) - dash
 
(void) - hatchPath:
 
(void) - hatchPath:objectAngle:
 Apply the hatching to the path with a given object angle. More...
 
(void) - invalidateCache
 
(CGFloat- leadIn
 
(NSLineCapStyle) - lineCapStyle
 
(NSLineJoinStyle) - lineJoinStyle
 
(CGFloat- roughness
 
(void) - setAngle:
 Set the angle of the hatching. More...
 
(void) - setAngleInDegrees:
 Set the angle of the hatching in degrees. More...
 
(void) - setAngleIsRelativeToObject:
 
(void) - setAutoDash
 
(void) - setColour:
 
(void) - setDash:
 
(void) - setLeadIn:
 
(void) - setLineCapStyle:
 
(void) - setLineJoinStyle:
 
(void) - setRoughness:
 
(void) - setSpacing:
 
(void) - setWidth:
 
(void) - setWobblyness:
 
(CGFloat- spacing
 
(CGFloat- width
 
(CGFloat- wobblyness
 
- Instance Methods inherited from DKRasterizer
(DKClippingOption) - clipping
 Whether the rasterizer's effect is clipped to the path or not, and if so, which side. More...
 
(DKRastGroup *) - container
 Returns the immediate container of this object, if owned by a group. More...
 
(BOOL- copyToPasteboard:
 
(BOOL- enabled
 
(BOOL- isValid
 
(NSString *) - label
 
(NSString *) - name
 
(NSBezierPath *) - renderingPathForObject:
 Returns the path to render given the object doing the rendering. More...
 
(void) - setClipping:
 
(void) - setClippingWithoutNotifying:
 
(void) - setContainer:
 Sets the immediate container of this object. More...
 
(void) - setEnabled:
 
(void) - setName:
 
(NSString *) - styleScript
 
- 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 <DKRasterizer>
(NSSize) - extraSpaceNeeded
 
(BOOL- isFill
 
(void) - render:
 
(void) - renderPath:
 
- Instance Methods inherited from <NSCoding>
(void) - encodeWithCoder:
 
(id- initWithCoder:
 
- Instance Methods inherited from <NSCopying>
(id- copyWithZone:
 

Class Methods

(DKHatching *) + defaultHatching
 Return the default hatching. More...
 
(DKHatching *) + hatchingWithDotDensity:
 Return a hatching which implements a dot pattern of given density. More...
 
(DKHatching *) + hatchingWithDotPitch:diameter:
 Return a hatching which implements a dot pattern. More...
 
(DKHatching *) + hatchingWithLineWidth:spacing:angle:
 Return a hatching with e basic parameters given. More...
 
- Class Methods inherited from DKRasterizer
(DKRasterizer *) + rasterizerFromPasteboard:
 
- 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:
 

Detailed Description

This class provides a simple hatching fill for a path.

This class provides a simple hatching fill for a path. It draws equally-spaced solid lines of a given thickness at a particular angle. Subclass for more sophisticated hatches.

Can be set as a fill style in a DKStyle object.

The hatch is cached in an NSBezierPath object based on the bounds of the path. If another path is hatched that is smaller than the cached size, it is not rebuilt. It is rebuilt if the angle or spacing changes or a bigger path is hatched. Linewidth also doesn't change the cache.

Method Documentation

- (CGFloat) angle

The angle of the hatching.

Returns
the angle in radians
- (CGFloat) angleInDegrees

The angle of the hatching in degrees.

Returns
the angle in degrees
- (BOOL) angleIsRelativeToObject
- (void) calcHatchInRect: (NSRect rect
- (NSColor*) colour
- (DKStrokeDash*) dash
+ (DKHatching*) defaultHatching

Return the default hatching.

Be sure to copy the object if you intend to change its parameters.

Returns
the default hatching object (shared instance). The default is black 45 degree lines spaced 8 points apart with a width of 0.25 points.
+ (DKHatching*) hatchingWithDotDensity: (CGFloat density

Return a hatching which implements a dot pattern of given density.

Dots have a diameter of 2.0 points, and are spaced according to density. If density = 1, dots touch (spacing = 2.0), 0.5 = dots have a spacing of 4.0, etc. A density of 0 is not allowed.

Parameters
densitya density figure from 0 to 1
Returns
a hatching instance having a dot pattern of the given density
+ (DKHatching*) hatchingWithDotPitch: (CGFloat pitch
diameter: (CGFloat diameter 

Return a hatching which implements a dot pattern.

The colour is set to black. The dot pattern is created using a dashed line at 45 degrees where the line and dash spacing is set to the dot pitch. The line width is the dot diameter and the rounded cap style is used. This is an efficient way to implement a dot pattern of a given density.

Parameters
pitchthe spacing between the dots
diameterthe dot diameter
Returns
a hatching instance having the given dot pattern
+ (DKHatching*) hatchingWithLineWidth: (CGFloat w
spacing: (CGFloat spacing
angle: (CGFloat angle 

Return a hatching with e basic parameters given.

The colour is set to black

Parameters
wthe line width of the lines
spacingthe line spacing
anglethe overall angle in radians
Returns
a hatching instance
- (void) hatchPath: (NSBezierPath *)  path
- (void) hatchPath: (NSBezierPath *)  path
objectAngle: (CGFloat oa 

Apply the hatching to the path with a given object angle.

Parameters
paththe path to fill
oathe additional angle to apply, in radians
- (void) invalidateCache
- (CGFloat) leadIn
- (NSLineCapStyle) lineCapStyle
- (NSLineJoinStyle) lineJoinStyle
- (CGFloat) roughness
- (void) setAngle: (CGFloat radians

Set the angle of the hatching.

Parameters
radiansthe angle in radians
- (void) setAngleInDegrees: (CGFloat degs

Set the angle of the hatching in degrees.

Parameters
degsthe angle in degrees
- (void) setAngleIsRelativeToObject: (BOOL rel
- (void) setAutoDash
- (void) setColour: (NSColor *)  colour
- (void) setDash: (DKStrokeDash *)  dash
- (void) setLeadIn: (CGFloat amount
- (void) setLineCapStyle: (NSLineCapStyle)  lcs
- (void) setLineJoinStyle: (NSLineJoinStyle)  ljs
- (void) setRoughness: (CGFloat amount
- (void) setSpacing: (CGFloat spacing
- (void) setWidth: (CGFloat width
- (void) setWobblyness: (CGFloat wobble
- (CGFloat) spacing
- (CGFloat) width
- (CGFloat) wobblyness