DrawKit
Vector and illustration framework for Mac OS X
|
DKDrawablePath is a drawable object that renders a path such as a line or curve (bezigon). More...
Instance Methods | |
(IBAction) | - addRandomNoise: |
Adds some random offset to every point on the path. More... | |
(void) | - arcCreateLoop: |
Event loop for creating an arc or a wedge. More... | |
(NSArray *) | - breakApart |
Converts each subpath in the current path to a separate object. More... | |
(IBAction) | - breakApart: |
Replaces the object with new objects, one for each subpath in the original. More... | |
(BOOL) | - canConvertToTrack |
(void) | - clearUndoPath |
(IBAction) | - closePath: |
Closes the path if not already closed. More... | |
(void) | - combine: |
Merges two paths by simply appending them. More... | |
(BOOL) | - constrainWithEvent: |
Should the angle of the path be constrained? More... | |
(IBAction) | - convertToOutline: |
Replaces the path with an outline of the path. More... | |
(IBAction) | - convertToShape: |
Converts this object to he equivalent shape. More... | |
(IBAction) | - curveFit: |
Attempts to curve-fit the object's path. More... | |
(DKDrawablePath *) | - dividePathAtLength: |
Splits a path into two paths at a specific point. More... | |
(void) | - drawControlPointsOfPath:usingKnobs: |
(void) | - freehandCreateLoop: |
Event loop for creating a curved path by fitting it to a series of sampled points. More... | |
(CGFloat) | - freehandSmoothing |
Get the smoothness valueof paths created in freehand mode. More... | |
(CGFloat) | - infoLengthForPath: |
Return the length to display to the user of a path. More... | |
(id) | - initWithBezierPath: |
(id) | - initWithBezierPath:style: |
Initialises a drawable path object from an existing path with the given style. More... | |
(BOOL) | - isOpenEndPoint: |
Discover whether the given partcode is an open end point of the path. More... | |
(BOOL) | - isPathClosed |
Discover whether the path is open or closed. More... | |
(DKDrawablePathJoinResult) | - join:tolerance:makeColinear: |
(CGFloat) | - length |
Return the length of the path. More... | |
(CGFloat) | - lengthForPoint: |
(CGFloat) | - lengthForPoint:tolerance: |
(void) | - lineCreateLoop: |
Event loop for creating a single straight line. More... | |
(DKDrawablePath *) | - makeParallelWithOffset:smooth: |
Make a copy of the path but with a parallel offset. More... | |
(DKDrawableShape *) | - makeShape |
Make a copy of the path into a shape object. More... | |
(void) | - movePathPartcode:toPoint:event: |
Move a single control point to a new position. More... | |
(IBAction) | - parallelCopy: |
Adds a copy of the receiver to the drawing with a parallel offset path. More... | |
(NSBezierPath *) | - path |
(void) | - pathCreateLoop: |
Event loop for creating a curved path point by point. More... | |
(void) | - pathCreationLoopDidEnd |
Overrideable hook at the end of path creation. More... | |
(DKDrawablePathCreationMode) | - pathCreationMode |
Gets the "mode" of operation for creating new path objects. More... | |
(BOOL) | - pathDeleteElementAtIndex: |
Delete a segment from the path at the given index. More... | |
(BOOL) | - pathDeleteElementAtPoint: |
Delete a segment from the path at the given point. More... | |
(BOOL) | - pathDeletePointWithPartCode: |
Delete the point from the path with the given part code. More... | |
(NSInteger) | - pathInsertPointAt:ofType: |
(void) | - polyCreateLoop: |
Event loop for creating a polygon consisting of straight line sections. More... | |
(NSEvent *) | - postMouseUpAtPoint: |
(void) | - recordPathForUndo |
(IBAction) | - reversePath: |
Reverses the direction of the object's path. More... | |
(IBAction) | - roughenPath: |
(void) | - setFreehandSmoothing: |
Set the smoothness of paths created in freehand mode. More... | |
(void) | - setPath: |
(void) | - setPathCreationMode: |
Sets the "mode" of operation for creating new path objects. More... | |
(void) | - setShouldExtendExistingPath: |
Set whether the object should extend its path or start from scratch. More... | |
(BOOL) | - shouldEndPathCreationWithEvent: |
Test for the ending criterion of a path loop. More... | |
(IBAction) | - smoothPath: |
Tries to smooth a path by curve fitting. More... | |
(IBAction) | - smoothPathMore: |
Tries to smooth a path by curve fitting. More... | |
(IBAction) | - toggleHorizontalFlip: |
Flips the path horizontally. More... | |
(IBAction) | - toggleVerticalFlip: |
Flips the path vertically. More... | |
(NSBezierPath *) | - undoPath |
(DKDrawablePathJoinResult) | - wouldJoin:tolerance: |
Preflights a potential join to determine if the join would be made. More... | |
Instance Methods inherited from DKDrawableObject | |
(void) | - addMetadata: |
(void) | - addUserInfo: |
(NSSet *) | - allRegisteredStyles |
(NSSet *) | - allStyles |
(CGFloat) | - angle |
(CGFloat) | - angleInDegrees |
Return the shape's current rotation angle. More... | |
(NSRect) | - apparentBounds |
(void) | - applyTransform: |
Apply the transform to the object. More... | |
(NSRect) | - bounds |
(NSImage *) | - cachedImage |
Returns an image of the object representing its current appearance at 100% scale. More... | |
(NSColor *) | - colourForKey: |
(id< DKDrawableContainer >) | - container |
Returns the immediate parent of this object. More... | |
(NSAffineTransform *) | - containerTransform |
Return the container's transform. More... | |
(CGFloat) | - convertLength: |
(NSPoint) | - convertPointToDrawing: |
(IBAction) | - copyDrawingStyle: |
(void) | - creationTool:willBeginCreationAtPoint: |
(void) | - creationTool:willEndCreationAtPoint: |
(NSView *) | - currentView |
(NSCursor *) | - cursorForPartcode:mouseButtonDown: |
(void) | - detachStyle |
If the object's style is currently sharable, copy it and make it non-sharable. More... | |
(void) | - drawContent |
(void) | - drawContentInRect:fromRect:withStyle: |
(void) | - drawContentWithSelectedState: |
(void) | - drawContentWithStyle: |
(void) | - drawGhostedContent |
(DKDrawing *) | - drawing |
(void) | - drawSelectedState |
(void) | - drawSelectionPath: |
(NSSize) | - extraSpaceNeeded |
(CGFloat) | - floatValueForKey: |
(NSUInteger) | - geometryChecksum |
(void) | - group:willUngroupObjectWithTransform: |
This object is being ungrouped from a group. More... | |
(void) | - groupWillAddObject: |
This object is being added to a group. More... | |
(BOOL) | - hasMetadataForKey: |
(NSInteger) | - hitPart: |
(NSInteger) | - hitSelectedPart:forSnapDetection: |
(NSUInteger) | - indexInContainer |
Returns the index position of this object in its container layer. More... | |
(id) | - initWithStyle: |
Initializes the drawable to have the style given. More... | |
(BOOL) | - intersectsRect: |
(NSInteger) | - intValueForKey: |
(void) | - invalidateRenderingCache |
Discard all cached rendering information. More... | |
(BOOL) | - isBeingHitTested |
Is a hit-test in progress. More... | |
(BOOL) | - isGhosted |
Retuirn whether the object is ghosted rather than with its full style. More... | |
(BOOL) | - isKeyObject |
Is the object currently the layer's key object? More... | |
(BOOL) | - isPendingObject |
Is the object currently a pending object? More... | |
(BOOL) | - isSelected |
(BOOL) | - isTrackingMouse |
(DKKnobType) | - knobTypeForPartCode: |
(DKObjectOwnerLayer *) | - layer |
Returns the layer that this object ultimately belongs to. More... | |
(NSPoint) | - location |
(BOOL) | - locationLocked |
Whether the object's location is locked or not. More... | |
(IBAction) | - lock: |
(BOOL) | - locked |
(IBAction) | - lockLocation: |
(NSRect) | - logicalBounds |
(NSMenu *) | - menu |
Reurn the menu to use as the object's contextual menu. More... | |
(NSMutableDictionary *) | - metadata |
(NSUInteger) | - metadataChecksum |
(void) | - metadataDidChangeKey: |
(DKMetadataItem *) | - metadataItemForKey: |
(DKMetadataItem *) | - metadataItemForKey:limitToLocalSearch: |
(NSArray *) | - metadataItemsForKeysInArray: |
(NSArray *) | - metadataItemsForKeysInArray:limitToLocalSearch: |
(NSArray *) | - metadataKeys |
(id) | - metadataObjectForKey: |
(void) | - metadataWillChangeKey: |
(void) | - mouseDoubleClickedAtPoint:inPart:event: |
(void) | - mouseDownAtPoint:inPart:event: |
(void) | - mouseDraggedAtPoint:inPart:event: |
(NSSize) | - mouseDragOffset |
(BOOL) | - mouseHasMovedSinceStartOfTracking |
(NSSize) | - mouseOffset |
(BOOL) | - mouseSnappingEnabled |
(void) | - mouseUpAtPoint:inPart:event: |
(void) | - notifyGeometryChange: |
(void) | - notifyStatusChange |
(void) | - notifyVisualChange |
(void) | - objectDidBecomeSelected |
(void) | - objectIsNoLongerSelected |
(BOOL) | - objectIsValid |
(BOOL) | - objectMayBecomeSelected |
Is the object able to be selected? More... | |
(void) | - objectWasAddedToLayer: |
The object was added to a layer. More... | |
(void) | - objectWasRemovedFromLayer: |
The object was removed from the layer. More... | |
(void) | - objectWasUngrouped |
This object was ungrouped from a group. More... | |
(NSSize) | - offset |
(void) | - offsetLocationByX:byY: |
(NSAttributedString *) | - originalText |
(IBAction) | - pasteDrawingStyle: |
(NSData *) | |
Returns the single object rendered as a PDF image. More... | |
(NSPoint) | - pointForPartcode: |
(BOOL) | - pointHitsPath: |
Test a point against the offscreen bitmap representation of the shape. More... | |
(BOOL) | - populateContextualMenu: |
(BOOL) | - populateContextualMenu:atPoint: |
(void) | - readSupplementaryDataFromPasteboard: |
Read additional data from the pasteboard specific to the object. More... | |
(BOOL) | - rectHitsPath: |
Test if a rect encloses any of the shape's actual pixels. More... | |
(void) | - removeMetadataForKey: |
(NSBezierPath *) | - renderingPath |
(void) | - replaceMatchingStylesFromSet: |
(void) | - resetOffset |
(void) | - resizeWidthBy:heightBy: |
(void) | - rotateByAngle: |
Rotate the shape by adding a delta angle to the current angle. More... | |
(DKMetadataSchema) | - schema |
(void) | - setAngle: |
Set the object's current angle in radians. More... | |
(void) | - setBeingHitTested: |
Set whether a hit-test in progress. More... | |
(void) | - setColour:forKey: |
(void) | - setContainer: |
(void) | - setFloatValue:forKey: |
(void) | - setGhosted: |
Set whether the object is ghosted rather than with its full style. More... | |
(void) | - setIntValue:forKey: |
(void) | - setLocation: |
(void) | - setLocationLocked: |
Sets whether the object's location is locked or not. More... | |
(void) | - setLocked: |
(void) | - setMetadata: |
(void) | - setMetadataItem:forKey: |
(void) | - setMetadataItemType:forKey: |
(void) | - setMetadataItemValue:forKey: |
(void) | - setMetadataObject:forKey: |
(void) | - setMouseDragOffset: |
(void) | - setMouseHasMovedSinceStartOfTracking: |
(void) | - setMouseSnappingEnabled: |
(void) | - setNeedsDisplayInRect: |
(void) | - setNeedsDisplayInRects: |
(void) | - setNeedsDisplayInRects:withExtraPadding: |
(void) | - setOffset: |
(void) | - setOriginalText: |
(void) | - setSize: |
(void) | - setSize:forKey: |
(void) | - setString:forKey: |
(void) | - setStyle: |
(void) | - setTrackingMouse: |
(void) | - setupMetadata |
(void) | - setUserInfo: |
(void) | - setUserInfoObject:forKey: |
Set an item of user info. More... | |
(void) | - setVisible: |
(NSSize) | - size |
(NSSize) | - sizeForKey: |
(NSPoint) | - snappedMousePoint:forSnappingPointsWithControlFlag: |
(NSPoint) | - snappedMousePoint:withControlFlag: |
Offset the point to cause snap to grid + guides accoding to the drawing's settings. More... | |
(NSArray *) | - snappingPoints |
(NSArray *) | - snappingPointsWithOffset: |
(NSString *) | - stringForKey: |
(DKStyle *) | - style |
(void) | - styleDidChange: |
(void) | - styleWillChange: |
(NSSet *) | - subSelection |
Return the subselection of the object. More... | |
(NSImage *) | - swatchImageWithSize: |
(NSAffineTransform *) | - transform |
Return a transform that maps the object's stored path to its true location in the drawing. More... | |
(NSUndoManager *) | - undoManager |
(IBAction) | - unlock: |
(IBAction) | - unlockLocation: |
(void) | - updateMetadataKeys |
(void) | - updateRulerMarkers |
(BOOL) | - useLowQualityDrawing |
(NSMutableDictionary *) | - userInfo |
Return the attached user info. More... | |
(id) | - userInfoObjectForKey: |
Return an item of user info. More... | |
(BOOL) | - visible |
(void) | - willBeAddedAsSubstituteFor:toLayer: |
Some high-level operations substitute a new object in place of an existing one (or several). More... | |
(void) | - writeSupplementaryDataToPasteboard: |
Write additional data to the pasteboard specific to the object. More... | |
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 <DKStorableObject> | |
(NSUInteger) | - index |
(BOOL) | - isMarked |
(void) | - setIndex: |
(void) | - setMarked: |
(void) | - setStorage: |
(id< DKObjectStorage >) | - storage |
Instance Methods inherited from <NSCoding> | |
(void) | - encodeWithCoder: |
(id) | - initWithCoder: |
Instance Methods inherited from <NSCopying> | |
(id) | - copyWithZone: |
Instance Methods inherited from <DKRenderable> | |
(NSMutableDictionary *) | - renderingCache |
Class Methods | |
(CGFloat) | + angularConstraintAngle |
Angle of constraint for new paths. More... | |
(BOOL) | + defaultOnPathHitDetectionPriority |
Returns whether the default hit-detection behaviour is to prioritise on-path points or off-path points. More... | |
(DKDrawablePath *) | + drawablePathWithBezierPath: |
Creates a drawable path object for an existing NSBezierPath. More... | |
(DKDrawablePath *) | + drawablePathWithBezierPath:withStyle: |
Creates a drawable path object for an existing NSBezierPath and style. More... | |
(NSColor *) | + infoWindowBackgroundColour |
Return the background colour to use for the info window displayed when interacting with paths. More... | |
(void) | + setAngularConstraintAngle: |
Set the angle of constraint for new paths. More... | |
(void) | + setDefaultOnPathHitDetectionPriority: |
Set whether the default hit-detection behaviour is to prioritise on-path points or off-path points. More... | |
(void) | + setInfoWindowBackgroundColour: |
Set the background colour to use for the info window displayed when interacting with paths. More... | |
Class Methods inherited from DKDrawableObject | |
(Class) | + classForConversionRequestFor: |
Return the class to use in place of the given class when performing a conversion. More... | |
(NSUInteger) | + countOfNativeObjectsOnPasteboard: |
Return the number of native objects held by the pasteboard. More... | |
(BOOL) | + displaysSizeInfoWhenDragging |
Return whether an info floater is displayed when resizing an object. More... | |
(NSColor *) | + ghostColour |
Return the outline colour to use when drawing objects in their ghosted state. More... | |
(NSInteger) | + initialPartcodeForObjectCreation |
(NSDictionary *) | + interconversionTable |
Return the interconversion table. More... | |
(BOOL) | + isGroupable |
Return whether obejcts of this class can be grouped. More... | |
(BOOL) | + metadataChangesAreUndoable |
(NSArray *) | + nativeObjectsFromPasteboard: |
(NSArray *) | + pasteboardTypesForOperation: |
(void) | + setDisplaysSizeInfoWhenDragging: |
Set whether an info floater is displayed when resizing an object. More... | |
(void) | + setGhostColour: |
Set the outline colour to use when drawing objects in their ghosted state. More... | |
(void) | + setInterconversionTable: |
Return the interconversion table. More... | |
(void) | + setMetadataChangesAreUndoable: |
(void) | + substituteClass:forClass: |
Sets the class to use in place of the a base class when performing a conversion. More... | |
(NSRect) | + unionOfBoundsOfDrawablesInArray: |
Returns the union of the bounds of the objects in the array. More... | |
Class Methods inherited from NSObject | |
(id) | + alloc |
(Class) | + class |
(void) | + initialize |
(void) | + load |
(id) | + new |
Class Methods inherited from <NSKeyValueBindingCreation> | |
(void) | + exposeBinding: |
Additional Inherited Members | |
Protected Attributes inherited from DKDrawableObject | |
BOOL | m_clipToBBox: 1 |
BOOL | m_showBBox: 1 |
BOOL | m_showPartcodes: 1 |
BOOL | m_showTargets: 1 |
BOOL | m_unused_padding: 4 |
DKDrawablePath is a drawable object that renders a path such as a line or curve (bezigon).
DKDrawablePath is a drawable object that renders a path such as a line or curve (bezigon).
The path is rendered at its stored size, not transformed to its final size like DKDrawableShape. Thus this type of object doesn't maintain the concept of rotation or scale - it just is what it is.
- (IBAction) addRandomNoise: | (id) | sender |
Adds some random offset to every point on the path.
Just a fun effect
sender | the action's sender |
+ (CGFloat) angularConstraintAngle |
Angle of constraint for new paths.
- (void) arcCreateLoop: | (NSPoint) | initialPoint |
Event loop for creating an arc or a wedge.
Keeps control until the ending criteria are met (second click).
initialPoint | where to start |
- (NSArray*) breakApart |
Converts each subpath in the current path to a separate object.
A subpath is a path delineated by a moveTo opcode. Each one is made a separate new path. If there is only one subpath (common) then the result will have just one entry.
- (IBAction) breakApart: | (id) | sender |
Replaces the object with new objects, one for each subpath in the original.
sender | the action's sender |
- (BOOL) canConvertToTrack |
- (void) clearUndoPath |
- (IBAction) closePath: | (id) | sender |
Closes the path if not already closed.
Paths created using the bezier tool are always left open by default
sender | the action's sender |
- (void) combine: | (DKDrawablePath *) | anotherPath |
Merges two paths by simply appending them.
This simply appends the part of the other object to this one and recomputes the bounds, etc. the result can act like a union, difference or XOR according to the relative placements of the paths and the winding rules in use.
anotherPath | another drawable path object like this one |
Should the angle of the path be constrained?
Returns yes if the shift key is currently held down, otherwise no.
- (IBAction) convertToOutline: | (id) | sender |
Replaces the path with an outline of the path.
The result depends on the style - specifically the maximum stroke width. The path is replaced by a path whose edges are where the edge of the stroke of the original path lie. The topmost stroke is used to set the fill of the resulting object's style. The result is similar but not always identical to the original. For complex styles you will lose a lot of information.
sender | the action's sender |
- (IBAction) convertToShape: | (id) | sender |
Converts this object to he equivalent shape.
Undoably replaces itself in its current layer by the equivalent shape object
sender | the action's sender |
Implemented in DKTextPath.
- (IBAction) curveFit: | (id) | sender |
Attempts to curve-fit the object's path.
The path might not change, depending on how it is made up
sender | the action's sender |
+ (BOOL) defaultOnPathHitDetectionPriority |
Returns whether the default hit-detection behaviour is to prioritise on-path points or off-path points.
Affects hit-detection when on-path and off-path points are coincident. Normally off-path points have priority, but an alternative approach is to have on-path points have priority, and the off-path points require the use of the command modifier key to be hit-detected. DK has previously always prioritised off-path points, but this setting allows you to change that for your app.
- (DKDrawablePath*) dividePathAtLength: | (CGFloat) | distance |
Splits a path into two paths at a specific point.
The new path has the same style and user info as the original, but is not added to the layer by this method. If <distance> is <= 0 or >= length, nil is returned.
distance | the position from the start of the path to make the split |
+ (DKDrawablePath*) drawablePathWithBezierPath: | (NSBezierPath *) | path |
Creates a drawable path object for an existing NSBezierPath.
Convenience method allows you to turn any path into a drawable that can be added to a drawing
path | the path to use |
+ (DKDrawablePath*) drawablePathWithBezierPath: | (NSBezierPath *) | path | |
withStyle: | (DKStyle *) | aStyle | |
Creates a drawable path object for an existing NSBezierPath and style.
Convenience method allows you to turn any path into a drawable that can be added to a drawing
path | the path to use |
aStyle | a style to apply to the path |
- (void) drawControlPointsOfPath: | (NSBezierPath *) | path | |
usingKnobs: | (DKKnob *) | knobs | |
- (void) freehandCreateLoop: | (NSPoint) | initialPoint |
Event loop for creating a curved path by fitting it to a series of sampled points.
Keeps control until the ending criteria are met (mouse up).
initialPoint | where to start |
- (CGFloat) freehandSmoothing |
Get the smoothness valueof paths created in freehand mode.
- (CGFloat) infoLengthForPath: | (NSBezierPath *) | path |
Return the length to display to the user of a path.
By default returns the same value as length. Override where the last path segment length should be shown instead of the total path length.
+ (NSColor*) infoWindowBackgroundColour |
Return the background colour to use for the info window displayed when interacting with paths.
- (id) initWithBezierPath: | (NSBezierPath *) | aPath |
- (id) initWithBezierPath: | (NSBezierPath *) | aPath | |
style: | (DKStyle *) | aStyle | |
Initialises a drawable path object from an existing path with the given style.
The path is retained, not copied
aPath | the path to use |
aStyle | the style to use |
Discover whether the given partcode is an open end point of the path.
A closed path always returns NO, as it has no open end points. An open path will return YES for only the first and last points.
partcode | a partcode to test |
- (BOOL) isPathClosed |
Discover whether the path is open or closed.
A path is closed if it has a closePath element or its first and last points are coincident.
- (DKDrawablePathJoinResult) join: | (DKDrawablePath *) | anotherPath | |
tolerance: | (CGFloat) | tol | |
makeColinear: | (BOOL) | colin | |
- (CGFloat) length |
Return the length of the path.
Length is accurately computed by summing the segment distances.
- (CGFloat) lengthForPoint: | (NSPoint) | mp |
- (CGFloat) lengthForPoint: | (NSPoint) | mp | |
tolerance: | (CGFloat) | tol | |
- (void) lineCreateLoop: | (NSPoint) | initialPoint |
Event loop for creating a single straight line.
Keeps control until the ending criteria are met (second click).
initialPoint | where to start |
- (DKDrawablePath*) makeParallelWithOffset: | (CGFloat) | distance | |
smooth: | (BOOL) | smooth | |
Make a copy of the path but with a parallel offset.
distance | the distance from the original that the path is offset (negative forupward displacement) |
smooth | if YES, also smooths the resulting path |
- (DKDrawableShape*) makeShape |
Make a copy of the path into a shape object.
Called by -convertToShape, a higher level operation. Note that the actual class of object returned can be modified by customising the interconversion table.
Move a single control point to a new position.
Essential interactive editing method
pc | the partcode for the point to be moved |
mp | the point to move it to |
evt | the event (used to grab modifier flags) |
- (IBAction) parallelCopy: | (id) | sender |
Adds a copy of the receiver to the drawing with a parallel offset path.
This is really just a test of the algorithm
sender | the action's sender |
- (NSBezierPath*) path |
- (void) pathCreateLoop: | (NSPoint) | initialPoint |
Event loop for creating a curved path point by point.
Keeps control until the ending criteria are met (double-click or click on first point).
initialPoint | where to start |
- (void) pathCreationLoopDidEnd |
Overrideable hook at the end of path creation.
- (DKDrawablePathCreationMode) pathCreationMode |
Gets the "mode" of operation for creating new path objects.
Delete a segment from the path at the given index.
If the element id removed from the middle, the path is split into two subpaths. If removed at either end, the path is shortened. Partcodes will change.
indx | the index of the element to delete |
- (BOOL) pathDeleteElementAtPoint: | (NSPoint) | loc |
Delete a segment from the path at the given point.
Finds the element hit by the point and calls -pathDeleteElementAtIndex:
loc | a point |
Delete the point from the path with the given part code.
Only on-path points of a curve are allowed to be deleted, not control points. The partcodes will be renumbered by this, so do not cache the partcode beyond this point.
pc | the partcode to delete |
- (NSInteger) pathInsertPointAt: | (NSPoint) | loc | |
ofType: | (DKDrawablePathInsertType) | pathPointType | |
- (void) polyCreateLoop: | (NSPoint) | initialPoint |
Event loop for creating a polygon consisting of straight line sections.
Keeps control until the ending criteria are met (double-click or click on start point).
initialPoint | where to start |
- (NSEvent*) postMouseUpAtPoint: | (NSPoint) | p |
- (void) recordPathForUndo |
- (IBAction) reversePath: | (id) | sender |
Reverses the direction of the object's path.
Does not change the path's appearance directly, but may depending on the current style, e.g. arrows will flip to the other end.
sender | the action's sender |
- (IBAction) roughenPath: | (id) | sender |
+ (void) setAngularConstraintAngle: | (CGFloat) | radians |
Set the angle of constraint for new paths.
radians | the angle to constrain by; multiples of angle are used |
+ (void) setDefaultOnPathHitDetectionPriority: | (BOOL) | priority |
Set whether the default hit-detection behaviour is to prioritise on-path points or off-path points.
Affects hit-detection when on-path and off-path points are coincident. Normally off-path points have priority, but an alternative approach is to have on-path points have priority, and the off-path points require the use of the command modifier key to be hit-detected. DK has previously always prioritised off-path points, but this setting allows you to change that for your app.
priority | if YES, on-path points have priority by default. |
- (void) setFreehandSmoothing: | (CGFloat) | fs |
Set the smoothness of paths created in freehand mode.
The bigger the number, the smoother but less accurate the path. The value is the distance in base units that a point has to be to the path to be considered a fit. Typical values are between 1 and 20
fs | a smoothness value |
+ (void) setInfoWindowBackgroundColour: | (NSColor *) | colour |
Set the background colour to use for the info window displayed when interacting with paths.
colour | the colour to use |
- (void) setPath: | (NSBezierPath *) | path |
- (void) setPathCreationMode: | (DKDrawablePathCreationMode) | editPathMode |
Sets the "mode" of operation for creating new path objects.
Paths are created by tools usually so this will be rarely needed. Pass 0 for the defalt mode which is to edit an existing path (once created all paths are logically the same)
editPathMode | a constant indicating how a new path should be constructed. |
- (void) setShouldExtendExistingPath: | (BOOL) | xtend |
Set whether the object should extend its path or start from scratch.
When YES, this affects the starting partcode for the creation process. Normally paths are started from scratch, but if YES, this extends the existing path from its end if the path is open. The tool that coordinates the creation of new objects is reposnsible for managing this appropriately.
xtend | YES to extend the path, NO for normal creation |
Test for the ending criterion of a path loop.
Currently only checks for a double-click
event | an event |
- (IBAction) smoothPath: | (id) | sender |
Tries to smooth a path by curve fitting.
If the path is already made up from bezier elements, this will have no effect. vector paths can benefit however.
The current set smoothness value is used
sender | the action's sender |
- (IBAction) smoothPathMore: | (id) | sender |
Tries to smooth a path by curve fitting.
If the path is already made up from bezier elements, this will have no effect. vector paths can benefit however.
The current set smoothness value x4 is used
sender | the action's sender |
- (IBAction) toggleHorizontalFlip: | (id) | sender |
Flips the path horizontally.
The path is flipped directly
sender | the action's sender |
- (IBAction) toggleVerticalFlip: | (id) | sender |
Flips the path vertically.
The path is flipped directly
sender | the action's sender |
- (NSBezierPath*) undoPath |
- (DKDrawablePathJoinResult) wouldJoin: | (DKDrawablePath *) | anotherPath | |
tolerance: | (CGFloat) | tol | |
Preflights a potential join to determine if the join would be made.
Allows a join operation to be preflighted without actually performing the join.
anotherPath | another drawable path object like this one |
tol | a value used to determine if the end points are placed sufficiently close to be joinable |