Skip to content

AppleCGPath

UBogun edited this page Jul 4, 2015 · 14 revisions

Inherits from AppleCFObject
Memory leak check: not yet done
Status: Almost Complete, callback functions untested, stroke methods missing

CGPath, also referred to as QuartzPath, is the immutable form of a vector path, much like Xojo's iOSPath (but this is mutable). iOSPath uses a really fast implementation of UIBezierPath, but sadly currently it doesn't forward an instance handle. Therefore this class is only useful until a handle property is added; you should use iOSPath whenever possible.

Creating an immutable path would be quite senseless if you couldn't define it afterwards. Therefore there's no creator here. You would rather use this class for examining returned path objects. For real use, the subclass AppeCGMutablePath will be a bit slower but mutable.

Additionally to the mutable subclass, you will also find convenience subclasses for fast creation of immutable geometric shapes: AppleCGPathEllipse, AppleCGPathRect, AppleCGPathRoundedRect

##Properties BoundingBox As NSRect (read-only): Returns the bounding box of the path.

CurrentPoint As NSPoint (read-only): The current point of the path in path coordinates.

isEmpty As Boolean (read-only): Exactly what the name suggests.

isRect As Boolean (read-only): True if the path is a rectangle.

PathBoundingBox As NSRect (read-only): Returns the path bounding box of the path. The path bounding box is the smallest rectangle completely enclosing all points in the path but not including control points for Bézier and quadratic curves.

##Methods Apply (Userdata as Ptr, Handler as Ptr): Calls a custom method on each of the path's Pathelements.
See PathApplyTemplate in the library for a method template that you could call.

ContainsPoint (aPoint as NSPoint, opt. EvenOddFill As Boolean = True, opt. Transform as CGAffineTransform) As Boolean: Returns True if the path contains aPoint. If EvenOddFill Is False, the Winding Fill rule is used for determining the path content. If you supply the Function with a CGAffine property, aPoint is transformed before calclulating the result.

Copy(opt. Transform as CGAffineTransform): Returns a copy of the path. If you supply a CGAfiineTransform structure, the path copy is transformed.

DefineCallBackFunction (InfoPtr As Ptr, PathElement As CGPathElement): See Apply. In this case, lets you perform the method on a selected element.

Equals (anotherPath As AppleCGPath) As Boolean: Returns true if both paths are equal.

isRectangle (aRect as NSRect) As Boolean: Like the isRect property, but returns a cgpath rectangle too if the path is a rectangle.

MutableCopy() As AppleCGMutablePath: Returns a mutable copy of the path.

Clone this wiki locally