OGWPath Class Reference
Inherits from | NSObject |
Declared in | OGWPath.h |
Overview
A simple and efficient path (array of points).
The array is an allocated block of memory instead of boxed NSValue objects. Buffer will grow as needed, allocating 50% more memory each time a boundary is hit.
Feature set is minimal. For example there are deliberately no “insert point” or “remove point” methods because they’re probably not going to be used (frequently).
Tasks
Creating a Path
Adding Points
Removing Points
Accessing Points
Enumerating Points
Modifying Path
Properties
Properties
Class Methods
pathWithCapacity:
Creates a path, reserving capacity amount of memory for points.
+ (id)pathWithCapacity:(GWUInteger)capacity
Parameters
- capacity
The initial capacity reserved for the array.
Return Value
A new instance.
See Also
Declared In
OGWPath.h
pathWithPoints:count:
Creates a path by copying count points from the points buffer (array). You are responsible to delete (free) your points buffer after calling this method.
+ (id)pathWithPoints:(GWPoint *)points count:(GWUInteger)count
Parameters
- points
A memory buffer containing GWPoints. The buffer is copied.
- count
The number of GWPoint in the buffer.
Return Value
A new instance.
See Also
Declared In
OGWPath.h
Instance Methods
addPoint:
Adds a single point to the array.
- (void)addPoint:(GWPoint)point
Parameters
- point
The point to add.
See Also
Declared In
OGWPath.h
addPoints:count:
Adds the given number of points from an existing GWPoint array or memory buffer.
- (void)addPoints:(GWPoint *)points count:(GWUInteger)count
Parameters
- points
Memeory buffer containing points. Buffer is copied.
- count
The number of GWPoint in the buffer.
See Also
Declared In
OGWPath.h
enumeratePointsUsingBlock:
Enumerates all path points.
- (void)enumeratePointsUsingBlock:(OGWPathEnumerationBlock)block
Parameters
- block
The block that is executed for each path point.
Declared In
OGWPath.h
enumeratePointsWithOptions:usingBlock:
Enumerates all path points with options.
- (void)enumeratePointsWithOptions:(NSEnumerationOptions)options usingBlock:(OGWPathEnumerationBlock)block
Parameters
- options
Currently the only valid option is NSEnumerationReverse to enumerate points in reverse order.
- block
The block that is executed for each path point.
See Also
Declared In
OGWPath.h
firstPoint
The first point in the path.
- (GWPoint)firstPoint
Return Value
The first point in the path.
See Also
Declared In
OGWPath.h
lastPoint
The last point in the path.
- (GWPoint)lastPoint
Return Value
The last point in the path.
See Also
Declared In
OGWPath.h
pointAtIndex:
Returns the point at the given index. If the index is out of bounds an exception is raised.
- (GWPoint)pointAtIndex:(GWUInteger)index
Parameters
- index
The index of a point.
Return Value
The point at the given index.
See Also
Declared In
OGWPath.h
removeLastPoint
Removes the last point from the array. Does nothing if the array is empty.
- (void)removeLastPoint
Declared In
OGWPath.h
removePointsStartingAtIndex:
Removes all points from index to last point. Does nothing if index >= count. The array then contains (index - 1) points.
- (void)removePointsStartingAtIndex:(GWUInteger)index
Parameters
- index
The lowest index from which to remove all remaining points.
See Also
Declared In
OGWPath.h
translate:
Translates the paths' points by the given point offset.
- (void)translate:(GWPoint)offset
Parameters
- offset
This offset is added to each path point.
Declared In
OGWPath.h