Path
public final class Path
Path
contain geometry. Path
may be empty, or contain one or more verbs that
outline a figure. Path
always starts with a move verb to a Cartesian coordinate,
and may be followed by additional verbs that add lines or curves.
Adding a close verb makes the geometry into a continuous loop, a closed contour.
Path
may contain any number of contours, each beginning with a move verb.
Path
contours may contain only a move verb, or may also contain lines,
quadratic beziers, conics, and cubic beziers. Path
contours may be open or
closed.
When used to draw a filled area, Path
describes whether the fill is inside or
outside the geometry. Path
also describes the winding rule used to fill
overlapping contours.
The various commands that add to the path provide a fluid interface, meaning that calling the methods return the instance on which it was invoked, easily allowing the drawing operations to be concatenated.
-
Constructs an empty
Path
. By default,Path
has no verbs, no points, and no weights. thefillType
is set to.winding
Declaration
Swift
public init()
-
Returns FillType, the rule used to fill Path. FillType of a new Path is .winding
Declaration
Swift
public var fillType: FillType { get set }
-
Undocumented
Declaration
Swift
public var convexity: Convexity { get set }
-
Returns the number of elements on the verb array containing the draw operations
Declaration
Swift
public var verbCount: Int32 { get }
-
Undocumented
Declaration
Swift
public var isConvex: Bool { get }
-
Undocumented
Declaration
Swift
public var isConcave: Bool { get }
-
Returns if
Path
is empty. EmptyPath
may have FillType but has noPoint
,Path.verb
, or conic weight.Path
() constructs emptyPath
; reset() and rewind() makePath
empty.Declaration
Swift
public var isEmpty: Bool { get }
-
Undocumented
Declaration
Swift
public var isOval: Bool { get }
-
Undocumented
Declaration
Swift
public var isRoundedRect: Bool { get }
-
Undocumented
Declaration
Swift
public var isLine: Bool { get }
-
Undocumented
Declaration
Swift
public var isRect: Bool { get }
-
Returns the number of points in SkPath. the count is initially zero.
Declaration
Swift
public var pointCount: Int32 { get }
-
Returns a mask, where each set bit corresponds to a SegmentMask constant if
Path
contains one or more verbs of that type. Returns zero ifPath
contains no lines, or curves: quads, conics, or cubics.egmentMasks
returns a cached result; it is very fast.Declaration
Swift
public var segmentMasks: SegmentMask { get }
-
Undocumented
Declaration
Swift
public var lastPoint: Point { get }
-
Returns minimum and maximum axes values of
Point
array. Returns (0, 0, 0, 0) ifPath
contains no points. Returned bounds width and height may be larger or smaller than area affected whenPath
is drawn.Rect
returned includes allPoint
added toPath
, includingPoint
associated with.move
that define empty contours.Declaration
Swift
public var bounds: Rect { get }
-
Returns minimum and maximum axes values of the lines and curves in
Path
. Returns (0, 0, 0, 0) ifPath
contains no points. Returned bounds width and height may be larger or smaller than area affected whenPath
is drawn. IncludesPoint
associated with.move
that define empty contours. Behaves identically tobounds
whenPath
contains only lines. IfPath
contains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower thanbounds
and unlikebounds
, does not cache the result.Declaration
Swift
public var tightBounds: Rect { get }
Return Value
tight bounds of curves in
Path
-
Undocumented
Declaration
Swift
public func getTightBounds() -> Rect?
-
Undocumented
Declaration
Swift
public func getOvalBounds() -> Rect?
-
Undocumented
Declaration
Swift
public func getRoundRect() -> RoundRect?
-
Undocumented
Declaration
Swift
public func getLine() -> [Point]?
-
Undocumented
-
Returns the point stored at the specified index, if this is out of bounds, it returns a point(0,0)
Declaration
Swift
public func getPoint(index: Int32) -> Point
-
Undocumented
Declaration
Swift
public func getPoints(maxPoints: Int32 = -1) -> [Point]
-
Returns true if the point (x, y) is contained by
Path
, taking into account FillType.Declaration
Swift
public func contains(x: Float, y: Float) -> Bool
Parameters
x
x-axis value of containment test
y
y-axis value of containment test
Return Value
true if
Point
is inPath
-
Undocumented
Declaration
Swift
public func offset(_ pt: Point)
-
Undocumented
Declaration
Swift
public func offset(x: Float, y: Float)
-
Undocumented
Declaration
Swift
@discardableResult public func move(to: Point) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func moveTo(_ x: Float, _ y: Float) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func rmove(to: Point) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func rmoveTo(_ x: Float, _ y: Float) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func line(to: Point) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func lineTo(_ x: Float, _ y: Float) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func rline(to: Point) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func rlineTo(_ x: Float, _ y: Float) -> Path
-
Undocumented
-
Undocumented
Declaration
-
Undocumented
Declaration
-
Undocumented
Declaration
-
Undocumented
Declaration
Swift
@discardableResult public func cubicTo(_ x0: Float, _ y0: Float, _ x1: Float, _ y1: Float, _ x2: Float, _ y2: Float) -> Path
-
Undocumented
Declaration
-
Undocumented
Declaration
Swift
@discardableResult public func rcubicTo(_ x0: Float, _ y0: Float, _ x1: Float, _ y1: Float, _ x2: Float, _ y2: Float) -> Path
-
Appends arc to
Path
. Arc is implemented by one or more conics weighted to describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc curves from lastPath
Point
to (x, y), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. Arc sweep is always less than 360 degrees. arcTo() appends line to (x, y) if either radii are zero, or if lastPath
Point
equals (x, y). arcTo() scales radii (rx, ry) to fit lastPath
Point
and (x, y) if both are greater than zero but too small. arcTo() appends up to four conic curves. arcTo() implements the functionality of SVG arc, although SVG sweep-flag value is opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while kCW_Direction cast to int is zero.Declaration
Parameters
radius
radius on x-axis and y-aix before x-axis, y-axis rotation
xAxisRotate
x-axis rotation in degrees; positive values are clockwise
largeArc
chooses smaller or larger arc
sweep
chooses clockwise or counterclockwise arc
end
end of arc
-
Appends arc to
Path
, relative to lastPath
Point
. Arc is implemented by one or more conic, weighted to describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc curves from lastPath
Point
to relative endPoint
: (dx, dy), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. IfPath
is empty, the start arcPoint
is (0, 0). Arc sweep is always less than 360 degrees. arcTo() appends line to endPoint
if either radii are zero, or if lastPath
Point
equals endPoint
. arcTo() scales radii (rx, ry) to fit lastPath
Point
and endPoint
if both are greater than zero but too small to describe an arc. arcTo() appends up to four conic curves. arcTo() implements the functionality of svg arc, although SVGsweep-flag
value is opposite the integer value of sweep; SVGsweep-flag
uses 1 for clockwise, while.direction
cast to int is zero.Declaration
Parameters
radius
radius before the rotation
xAxisRotate
x-axis rotation in degrees; positive values are clockwise
largeArc
chooses smaller or larger arc
sweep
chooses clockwise or counterclockwise arc
offset
offset end of arc from last
Path
Point
-
Appends arc to
Path
. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise. arcTo() adds line connectingPath
lastPoint
to initial arcPoint
if forceMoveTo is false andPath
is not empty. Otherwise, added contour begins with first point of arc. Angles greater than -360 and less than 360 are treated modulo 360.Declaration
Swift
@discardableResult public func arcTo(oval: Rect, startAngle: Float, sweepAngle: Float, forceMoveTo: Bool) -> Path
Parameters
oval
bounds of ellipse containing arc
startAngle
starting angle of arc in degrees
sweepAngle
sweep, in degrees. Positive is clockwise; treated modulo 360
forceMoveTo
true to start a new contour with arc
-
Appends arc to
Path
, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from lastPath
point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc is part of circle sized to radius, positioned so it touches both tangent lines. If last Path Point does not start Arc, arcTo appends connecting Line to Path. The length of Vector from (x1, y1) to (x2, y2) does not affect Arc. Arc sweep is always less than 180 degrees. If radius is zero, or if tangents are nearly parallel, arcTo appends Line from last Path Point to (x1, y1). arcTo appends at most one Line and one conic. arcTo implements the functionality of PostScript arct and HTML Canvas arcTo.Declaration
Swift
@discardableResult public func arcTo(x1: Float, y1: Float, x2: Float, y2: Float, radius: Float) -> Path
Parameters
x1
x-axis value common to pair of tangents
y1
y-axis value common to pair of tangents
x2
x-axis value end of second tangent
y2
y-axis value end of second tangent
radius
distance from arc to circle center
-
Appends
.close
toPath
. A closed contour connects the first and lastPoint
with line, forming a continuous loop. Open and closed contour draw the same withPaint.Fill
. WithPaint.Stroke
, open contour drawsPaint.Cap
at contour start and end; closed contour drawsPaint.Join
::Join at contour start and end. close() has no effect ifPath
is empty or lastPath
.close
Declaration
Swift
public func close()
-
Sets
Path
to its initial state, preserving internal storage. Removes verb array,Point
array, and weights, and sets FillType to kWinding_FillType. Internal storage associated withPath
is retained. Use rewind() instead of reset() ifPath
storage will be reused and performance is critical.Declaration
Swift
public func rewind()
-
Sets
Path
to its initial state. Removes verb array,Point
array, and weights, and sets FillType to kWinding_FillType. Internal storage associated withPath
is released.Declaration
Swift
public func reset()
-
Add Rect to the path, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir is .clockwise direction; or followed by bottom-left, bottom-right, and top-right if dir is .counterClockwise direction
Declaration
Parameters
rect
Rect to add as a closed contour
dir
Direction to wind added contour
-
Add Rect to the path, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir is .clockwise direction; or followed by bottom-left, bottom-right, and top-right if dir is .counterClockwise direction
Declaration
Parameters
rect
Rect to add as a closed contour
dir
Direction to wind added contour
start
index of initial point of Rect
-
Append RoundedRect to the path, creating a new closed contour. RRect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If dir is .clockwise, RRect starts at top-left of the lower-left corner and winds clockwise. If dir is .counterClockwise, RRect starts at the bottom-left of the upper-left corner and winds counterclockwise.
If either rx or ry is too large, rx and ry are scaled uniformly until the corners fit. If rx or ry is less than or equal to zero, the method appends the Rect rect to the path. After appending, Path may be empty, or may contain: Rect, Oval, or RoundRect.
Declaration
Parameters
roundedRect
bounds of the rectangle
-
Append RoundedRect to the path, creating a new closed contour. RRect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If dir is .clockwise, RRect starts at top-left of the lower-left corner and winds clockwise. If dir is .counterClockwise, RRect starts at the bottom-left of the upper-left corner and winds counterclockwise.
If either rx or ry is too large, rx and ry are scaled uniformly until the corners fit. If rx or ry is less than or equal to zero, the method appends the Rect rect to the path. After appending, Path may be empty, or may contain: Rect, Oval, or RoundRect.
Declaration
Parameters
roundedRect
bounds of the rectangle
start
index of initial point of RRect
-
Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. Oval is upright ellipse bounded by
Rect
oval with radii equal to half oval width and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.Declaration
Parameters
rect
bounds of ellipse added
direction
Path
::Direction to wind ellipse -
Append arc to the path, as the start of new contour. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.
If sweepAngle is less than -360, or sweepAngle is larger than 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle values are treated modulo 360, and arc may or may not draw depending on numeric rounding.
Declaration
Swift
@discardableResult public func addArc(_ rect: Rect, startAngle: Float, sweepAngle: Float) -> Path
Parameters
oval
bounds of ellipse containing arc
startAngle
starting angle of arc in degrees
-
Transform verb array, Point array, and weight by matrix. transform may change verbs and increase their number. Path is replaced by transformed data.
Declaration
Swift
public func transform(matrix: Matrix)
-
Undocumented
See moreDeclaration
Swift
public enum PathAddMode
-
Undocumented
Declaration
Swift
@discardableResult public func addPath(_ other: Path, dx: Float, dy: Float, mode: PathAddMode = .append) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func addPath(_ other: Path, mode: PathAddMode = .append) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func addPath(_ other: Path, matrix: Matrix, mode: PathAddMode = .append) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func addPathReverse(_ other: Path) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func addCircle(x: Float, y: Float, radius: Float, direction: Direction = .clockwise) -> Path
-
Undocumented
Declaration
Swift
@discardableResult public func addPoly(points: [Point], close: Bool = true) -> Path
-
Undocumented
Declaration
Swift
public func op(other: Path, op: Op, result: Path) -> Bool
-
Undocumented
Declaration
Swift
public func op(other: Path, op localop: Op) -> Path?
-
Undocumented
Declaration
Swift
public func simplify(result: Path)
-
Undocumented
Declaration
Swift
public func simplify() -> Path
-
Undocumented
Declaration
Swift
public func toSvgPathData() -> String
-
Undocumented
Declaration
Swift
public static func parseSvgPathData(svgPath: String) -> Path?
-
Four oval parts with radii (rx, ry) start at last SkPath SkPoint and ends at (x, y). Size and Direction select one of the four oval parts.
See moreDeclaration
Swift
public enum Size : UInt32
-
FillType selects the rule used to fill
See morePath
.Path
set to.winding
fills if the sum of contour edges is not zero, where clockwise edges add one, and counterclockwise edges subtract one.Path
set to.evenOdd
fills if the number of contour edges is odd. Each FillType has an inverse variant that reverses the rule:.inverseWinding
fills where the sum of contour edges is zero;.inverseEvenOdd
fills where the number of contour edges is even.Declaration
Swift
public enum FillType : UInt32
-
Path
is convex if it contains one contour and contour loops no more than 360 degrees, and contour angles all have same Direction. ConvexPath
may have better performance and require fewer resources on GPU surface.Path
is concave when either at least one Direction change is clockwise and another is counterclockwise, or the sum of the changes in Direction is not 360 degrees.Initially
See morePath
Convexity is kUnknown_Convexity.Path
Convexity is computed f needed by destinationSurface
.Declaration
Swift
public enum Convexity : UInt32
-
SegmentMask constants correspond to each drawing Verb type in Path; for instance, if Path only contains lines, only the
See more.line
bit is set.Declaration
Swift
public enum SegmentMask : UInt32
-
PathDirection
describes whether contour is clockwise or counterclockwise. WhenPath
contains multiple overlapping contours,PathDirection
together withFillType
determines whether overlaps are filled or form holes.PathDirection
also determines how contour is measured. For instance, dashing measures alongPath
to determine where to start and stop stroke;PathDirection
will change dashed results as it steps clockwise or counterclockwise.Closed contours like
See moreRect
,RRect
, circle, and oval added with.clockwise
travel clockwise; the same added with.counterclockwise
travel counterclockwise.Declaration
Swift
public enum Direction : UInt32
-
The logical operations that can be performed when combining two paths
See moreDeclaration
Swift
public enum Op : UInt32