SkPath Reference


Paths contain geometry. Paths 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. Paths 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.

Internally, Path lazily computes metrics likes bounds and convexity. Call SkPath::updateBoundsCache to make Path thread safe.


Verb instructs Path how to interpret one or more Point and optional Conic_Weight; manage Contour, and terminate Path.

Constants

VerbAllocated PointsIterated PointsWeights
kMove_Verb110
kLine_Verb120
kQuad_Verb230
kConic_Verb231
kCubic_Verb340
kClose_Verb010
kDone_Verb--00

Example

Example Output

verb count: 7
verbs: kMove_Verb kLine_Verb kQuad_Verb kClose_Verb kMove_Verb kCubic_Verb kConic_Verb


Direction describes whether Contour is clockwise or counterclockwise. When Path contains multiple overlapping Contours, Direction together with Fill_Type determines whether overlaps are filled or form holes.

Direction also determines how Contour is measured. For instance, dashing measures along Path to determine where to start and stop stroke; Direction will change dashed results as it steps clockwise or counterclockwise.

Closed Contours like Rect, Round_Rect, Circle, and Oval added with kCW_Direction travel clockwise; the same added with kCCW_Direction travel counterclockwise.

Constants

Example

See Also

arcTo rArcTo isRect isNestedFillRects addRect addOval


Constructs an empty SkPath. By default, SkPath has no verbs, no SkPoint, and no weights. SkPath::FillType is set to kWinding_FillType.

Return Value

empty SkPath

Example

Example Output

path is empty

See Also

reset rewind


Constructs a copy of an existing path. Copy constructor makes two paths identical by value. Internally, path and the returned result share pointer values. The underlying verb array, SkPoint array and weights are copied when modified.

Creating a SkPath copy is very efficient and never allocates memory. SkPath are always copied by value from the interface; the underlying shared pointers are not exposed.

Parameters

Return Value

copy of SkPath

Example

Example Output

path verbs: 2
path2 verbs: 3
after reset
path verbs: 0
path2 verbs: 3

See Also

operator=(const SkPath& path)


Releases ownership of any shared data and deletes data if SkPath is sole owner.

Example

See Also

SkPath() SkPath(const SkPath& path) operator=(const SkPath& path)


Constructs a copy of an existing path. SkPath assignment makes two paths identical by value. Internally, assignment shares pointer values. The underlying verb array, SkPoint array and weights are copied when modified.

Copying SkPath by assignment is very efficient and never allocates memory. SkPath are always copied by value from the interface; the underlying shared pointers are not exposed.

Parameters

Return Value

SkPath copied by value

Example

Example Output

path1 bounds = 10, 20, 30, 40
path2 bounds = 10, 20, 30, 40

See Also

swap SkPath(const SkPath& path)


Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights are equivalent.

Parameters

Return Value

true if SkPath pair are equivalent

Example

Example Output

empty one == two
moveTo one != two
rewind one == two
reset one == two

See Also

operator!=(const SkPath& a, const SkPath& b) operator=(const SkPath& path)


Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights are not equivalent.

Parameters

Return Value

true if SkPath pair are not equivalent

Example

Example Output

empty one == two
add rect one == two
setConvexity one == two
convexity !=


Returns true if SkPath contain equal verbs and equal weights. If SkPath contain one or more conics, the weights must match.

conicTo() may add different verbs depending on conic weight, so it is not trivial to interpolate a pair of SkPath containing conics with different conic weight values.

Parameters

Return Value

true if SkPath verb array and weights are equivalent

Example

Example Output

paths are interpolatable

See Also

isInterpolatable


Interpolates between Paths with Point_Array of equal size. Copy Verb_Array and Weights to out, and set out Point_Array to a weighted average of this Point_Array and ending Point_Array, using the formula: (Path Point * weight) + ending Point * (1 - weight).

weight is most useful when between zero (ending Point_Array) and one (this Point_Array); will work with values outside of this range.

interpolate() returns false and leaves out unchanged if Point_Array is not the same size as ending Point_Array. Call isInterpolatable to check Path compatibility prior to calling interpolate().

Parameters

Return Value

true if Paths contain same number of Points

Example

See Also

isInterpolatable


Fill_Type selects the rule used to fill Path. Path set to kWinding_FillType fills if the sum of Contour edges is not zero, where clockwise edges add one, and counterclockwise edges subtract one. Path set to kEvenOdd_FillType fills if the number of Contour edges is odd. Each Fill_Type has an inverse variant that reverses the rule: kInverseWinding_FillType fills where the sum of Contour edges is zero; kInverseEvenOdd_FillType fills where the number of Contour edges is even.

Example

Constants

Example

See Also

SkPaint::Style Direction getFillType setFillType


Returns FillType, the rule used to fill SkPath. FillType of a new SkPath is kWinding_FillType.

Return Value

one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,

kInverseEvenOdd_FillType

Example

Example Output

default path fill type is kWinding_FillType

See Also

FillType setFillType isInverseFillType


Sets FillType, the rule used to fill SkPath. While there is no check that ft is legal, values outside of FillType are not supported.

Parameters

kInverseEvenOdd_FillType

Example

See Also

FillType getFillType toggleInverseFillType


Returns if FillType describes area outside SkPath geometry. The inverse fill area extends indefinitely.

Return Value

true if FillType is kInverseWinding_FillType or kInverseEvenOdd_FillType

Example

Example Output

default path fill type is inverse: false

See Also

FillType getFillType setFillType toggleInverseFillType


Replaces FillType with its inverse. The inverse of FillType describes the area unmodified by the original FillType.

FillTypetoggled FillType
kWinding_FillTypekInverseWinding_FillType
kEvenOdd_FillTypekInverseEvenOdd_FillType
kInverseWinding_FillTypekWinding_FillType
kInverseEvenOdd_FillTypekEvenOdd_FillType

Example

See Also

FillType getFillType setFillType isInverseFillType


Path is convex if it contains one Contour and Contour loops no more than 360 degrees, and Contour angles all have same Direction. Convex Path 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 Path Convexity is kUnknown_Convexity. Path Convexity is computed if needed by destination Surface.

Constants

Example

See Also

Contour Direction getConvexity getConvexityOrUnknown setConvexity isConvex


Computes SkPath::Convexity if required, and returns stored value. SkPath::Convexity is computed if stored value is kUnknown_Convexity, or if SkPath has been altered since SkPath::Convexity was computed or set.

Return Value

computed or stored SkPath::Convexity

Example

See Also

Convexity Contour Direction getConvexityOrUnknown setConvexity isConvex


Returns last computed SkPath::Convexity, or kUnknown_Convexity if SkPath has been altered since SkPath::Convexity was computed or set.

Return Value

stored SkPath::Convexity

Example

See Also

Convexity Contour Direction getConvexity setConvexity isConvex


Stores convexity so that it is later returned by getConvexity() or getConvexityOrUnknown(). convexity may differ from getConvexity(), although setting an incorrect value may cause incorrect or inefficient drawing.

If convexity is kUnknown_Convexity: getConvexity() will compute SkPath::Convexity, and getConvexityOrUnknown() will return kUnknown_Convexity.

If convexity is kConvex_Convexity or kConcave_Convexity, getConvexity() and getConvexityOrUnknown() will return convexity until the path is altered.

Parameters

Example

See Also

Convexity Contour Direction getConvexity getConvexityOrUnknown isConvex


Computes SkPath::Convexity if required, and returns true if value is kConvex_Convexity. If setConvexity() was called with kConvex_Convexity or kConcave_Convexity, and the path has not been altered, SkPath::Convexity is not recomputed.

Return Value

true if SkPath::Convexity stored or computed is kConvex_Convexity

Example

See Also

Convexity Contour Direction getConvexity getConvexityOrUnknown setConvexity


Returns true if this path is recognized as an oval or circle.

bounds receives bounds of oval.

bounds is unmodified if oval is not found.

Parameters

Return Value

true if SkPath is recognized as an oval or circle

Example

See Also

Oval addCircle addOval


Returns true if path is representable as SkRRect. Returns false if path is representable as oval, circle, or SkRect.

rrect receives bounds of SkRRect.

rrect is unmodified if SkRRect is not found.

Parameters

Return Value

true if SkPath contains only SkRRect

Example

See Also

Round_Rect addRoundRect addRRect


Sets SkPath to its initial state. Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType. Internal storage associated with SkPath is released.

Return Value

reference to SkPath

Example

See Also

rewind()


Sets SkPath to its initial state, preserving internal storage. Removes verb array, SkPoint array, and weights, and sets FillType to kWinding_FillType. Internal storage associated with SkPath is retained.

Use rewind() instead of reset() if SkPath storage will be reused and performance is critical.

Return Value

reference to SkPath

Example

See Also

reset()


Returns if SkPath is empty. Empty SkPath may have FillType but has no SkPoint, SkPath::Verb, or conic weight. SkPath() constructs empty SkPath; reset() and rewind() make SkPath empty.

Return Value

true if the path contains no SkPath::Verb array

Example

Example Output

initial path is empty
after moveTo path is not empty
after rewind path is empty
after lineTo path is not empty
after reset path is empty

See Also

SkPath() reset() rewind()


Returns if contour is closed. Contour is closed if SkPath SkPath::Verb array was last modified by close(). When stroked, closed contour draws SkPaint::Join instead of SkPaint::Cap at first and last SkPoint.

Return Value

true if the last contour ends with a kClose_Verb

Example

Example Output

initial last contour is not closed
after close last contour is not closed
after lineTo last contour is not closed
after close last contour is closed

See Also

close()


Returns true for finite SkPoint array values between negative SK_ScalarMax and positive SK_ScalarMax. Returns false for any SkPoint array value of SK_ScalarInfinity, SK_ScalarNegativeInfinity, or SK_ScalarNaN.

Return Value

true if all SkPoint values are finite

Example

Example Output

initial path is finite
after line path is finite
after scale path is not finite

See Also

SkScalar


Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn. SkPath by default have volatile set false, allowing SkSurface to attach a cache of data which speeds repeated drawing. If true, SkSurface may not speed repeated drawing.

Return Value

true if caller will alter SkPath after drawing

Example

Example Output

volatile by default is false

See Also

setIsVolatile


Specifies whether SkPath is volatile; whether it will be altered or discarded by the caller after it is drawn. SkPath by default have volatile set false, allowing SkBaseDevice to attach a cache of data which speeds repeated drawing.

Mark temporary paths, discarded or modified after use, as volatile to inform SkBaseDevice that the path need not be cached.

Mark animating SkPath volatile to improve performance. Mark unchanging SkPath non-volatile to improve repeated rendering.

raster surface SkPath draws are affected by volatile for some shadows. GPU surface SkPath draws are affected by volatile for some shadows and concave geometries.

Parameters

Example

See Also

isVolatile


Tests if line between SkPoint pair is degenerate. Line with no length or that moves a very short distance is degenerate; it is treated as a point.

exact changes the equality test. If true, returns true only if p1 equals p2. If false, returns true if p1 equals or nearly equals p2.

Parameters

Return Value

true if line is degenerate; its length is effectively zero

Example

Example Output

line from (100,100) to (100,100) is degenerate, nearly
line from (100,100) to (100,100) is degenerate, exactly
line from (100,100) to (100.0001,100.0001) is degenerate, nearly
line from (100,100) to (100.0001,100.0001) is not degenerate, exactly

See Also

IsQuadDegenerate IsCubicDegenerate


Tests if quad is degenerate. Quad with no length or that moves a very short distance is degenerate; it is treated as a point.

Parameters

if false, returns true if p1, p2, and p3 are equal or nearly equal

Return Value

true if quad is degenerate; its length is effectively zero

Example

Example Output

quad (100,100), (100.00001,100.00001), (100.00002,100.00002) is degenerate, nearly
quad (1100,1100), (1100,1100), (1100,1100) is degenerate, nearly
quad (100,100), (100.00001,100.00001), (100.00002,100.00002) is not degenerate, exactly
quad (1100,1100), (1100,1100), (1100,1100) is degenerate, exactly

See Also

IsLineDegenerate IsCubicDegenerate


Tests if cubic is degenerate. Cubic with no length or that moves a very short distance is degenerate; it is treated as a point.

Parameters

if false, returns true if p1, p2, p3, and p4 are equal or nearly equal

Return Value

true if cubic is degenerate; its length is effectively zero

Example

Example Output

0.00024414062 is degenerate
0.00024414065 is length


Returns true if SkPath contains only one line; SkPath::Verb array has two entries: kMove_Verb, kLine_Verb. If SkPath contains one line and line is not nullptr, line is set to line start point and line end point. Returns false if SkPath is not one line; line is unaltered.

Parameters

Return Value

true if SkPath contains exactly one line

Example

Example Output

empty is not line
zero line is line (0,0) (0,0)
line is line (10,10) (20,20)
second move is not line

Point_Array contains Points satisfying the allocated Points for each Verb in Verb_Array. For instance, Path containing one Contour with Line and Quad is described by Verb_Array: kMove_Verb, kLine_Verb, kQuad_Verb; and one Point for move, one Point for Line, two Points for Quad; totaling four Points.

Point_Array may be read directly from Path with getPoints, or inspected with getPoint, with Iter, or with RawIter.


Returns number of points in SkPath. Up to max points are copied. points may be nullptr; then, max must be zero. If max is greater than number of points, excess points storage is unaltered.

Parameters

Return Value

SkPath SkPoint array length

Example

Example Output

no points point count: 3
zero max point count: 3
too small point count: 3  (0,0) (20,20)
just right point count: 3  (0,0) (20,20) (-10,-10)

See Also

countPoints getPoint


Returns the number of points in SkPath. SkPoint count is initially zero.

Return Value

SkPath SkPoint array length

Example

Example Output

empty point count: 0
zero line point count: 2
line point count: 2
second move point count: 3

See Also

getPoints


Returns SkPoint at index in SkPoint array. Valid range for index is 0 to countPoints() - 1. Returns (0, 0) if index is out of range.

Parameters

Return Value

SkPoint array value or (0, 0)

Example

Example Output

point 0: (-10,-10)
point 1: (10,10)

See Also

countPoints getPoints

Verb_Array always starts with kMove_Verb. If kClose_Verb is not the last entry, it is always followed by kMove_Verb; the quantity of kMove_Verb equals the Contour count. Verb_Array does not include or count kDone_Verb; it is a convenience returned when iterating through Verb_Array.

Verb_Array may be read directly from Path with getVerbs, or inspected with Iter, or with RawIter.


Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb, kCubic_Verb, and kClose_Verb; added to SkPath.

Return Value

length of verb array

Example

Example Output

empty verb count: 0
round rect verb count: 10

See Also

getVerbs Iter RawIter


Returns the number of verbs in the path. Up to max verbs are copied. The verbs are copied as one byte per verb.

Parameters

Return Value

the actual number of verbs in the path

Example

Example Output

no verbs verb count: 3
zero max verb count: 3
too small verb count: 3  move line
just right verb count: 3  move line line

See Also

countVerbs getPoints Iter RawIter


Exchanges the verb array, SkPoint array, weights, and SkPath::FillType with other. Cached state is also exchanged. swap() internally exchanges pointers, so it is lightweight and does not allocate memory.

swap() usage has largely been replaced by operator=(const SkPath& path). SkPath do not copy their content on assignment until they are written to, making assignment as efficient as swap().

Parameters

Example

Example Output

path1 bounds = 0, 0, 0, 0
path2 bounds = 10, 20, 30, 40

See Also

operator=(const SkPath& path)


Returns minimum and maximum axes values of SkPoint array. Returns (0, 0, 0, 0) if SkPath contains no points. Returned bounds width and height may be larger or smaller than area affected when SkPath is drawn.

SkRect returned includes all SkPoint added to SkPath, including SkPoint associated with kMove_Verb that define empty contours.

Return Value

bounds of all SkPoint in SkPoint array

Example

Example Output

empty bounds = 0, 0, 0, 0
circle bounds = 25, 20, 75, 70
rotated circle bounds = 14.6447, 9.64466, 85.3553, 80.3553

See Also

computeTightBounds updateBoundsCache


Updates internal bounds so that subsequent calls to getBounds() are instantaneous. Unaltered copies of SkPath may also access cached bounds through getBounds().

For now, identical to calling getBounds() and ignoring the returned value.

Call to prepare SkPath subsequently drawn from multiple threads, to avoid a race condition where each draw separately computes the bounds.

Example

Example Output

#Volatile
uncached avg: 0.18048 ms
cached avg: 0.182784 ms

See Also

getBounds


Returns minimum and maximum axes values of the lines and curves in SkPath. Returns (0, 0, 0, 0) if SkPath contains no points. Returned bounds width and height may be larger or smaller than area affected when SkPath is drawn.

Includes SkPoint associated with kMove_Verb that define empty contours.

Behaves identically to getBounds() when SkPath contains only lines. If SkPath contains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower than getBounds(); and unlike getBounds(), does not cache the result.

Return Value

tight bounds of curves in SkPath

Example

Example Output

empty bounds = 0, 0, 0, 0
circle bounds = 25, 20, 75, 70
rotated circle bounds = 25, 20, 75, 70

See Also

getBounds


Returns true if rect is contained by SkPath. May return false when rect is contained by SkPath.

For now, only returns true if SkPath has one contour and is convex. rect may share points and edges with SkPath and be contained. Returns true if rect is empty, that is, it has zero width or height; and the SkPoint or line described by rect is contained by SkPath.

Parameters

Return Value

true if rect is contained

Example

See Also

contains Op Rect Convexity


Grows SkPath verb array and SkPoint array to contain extraPtCount additional SkPoint. May improve performance and use less memory by reducing the number and size of allocations when creating SkPath.

Parameters

Example

See Also

Point_Array


Shrinks SkPath verb array and SkPoint array storage to discard unused capacity. May reduce the heap overhead for SkPath known to be fully constructed.

See Also

incReserve


Adds beginning of contour at SkPoint (x, y).

Parameters

Return Value

reference to SkPath

Example

See Also

Contour lineTo rMoveTo quadTo conicTo cubicTo close()


Adds beginning of contour at SkPoint p.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour lineTo rMoveTo quadTo conicTo cubicTo close()


Adds beginning of contour relative to last point. If SkPath is empty, starts contour at (dx, dy). Otherwise, start contour at last point offset by (dx, dy). Function name stands for “relative move to”.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour lineTo moveTo quadTo conicTo cubicTo close()


Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding line.

lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed. lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo rLineTo addRect


Adds line from last point to SkPoint p. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding line.

lineTo() first appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed. lineTo() then appends kLine_Verb to verb array and SkPoint p to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo rLineTo addRect


Adds line from last point to vector (dx, dy). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding line.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kLine_Verb to verb array and line end to SkPoint array. Line end is last point plus vector (dx, dy). Function name stands for “relative line to”.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo lineTo addRect


Quad describes a Quadratic_Bezier, a second-order curve identical to a section of a parabola. Quad begins at a start Point, curves towards a control Point, and then curves to an end Point.

Example

Quad is a special case of Conic where Conic_Weight is set to one.

Quad is always contained by the triangle connecting its three Points. Quad begins tangent to the line between start Point and control Point, and ends tangent to the line between control Point and end Point.

Example


Adds quad from last point towards (x1, y1), to (x2, y2). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array; and (x1, y1), (x2, y2) to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo conicTo rQuadTo


Adds quad from last point towards SkPoint p1, to SkPoint p2. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array; and SkPoint p1, p2 to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo conicTo rQuadTo


Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array; and appends quad control and quad end to SkPoint array. Quad control is last point plus vector (dx1, dy1). Quad end is last point plus vector (dx2, dy2). Function name stands for “relative quad to”.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo conicTo quadTo

Conic describes a conical section: a piece of an ellipse, or a piece of a parabola, or a piece of a hyperbola. Conic begins at a start Point, curves towards a control Point, and then curves to an end Point. The influence of the control Point is determined by Conic_Weight.

Each Conic in Path adds two Points and one Conic_Weight. Conic_Weights in Path may be inspected with Iter, or with RawIter.


Weight determines both the strength of the control Point and the type of Conic. Weight varies from zero to infinity. At zero, Weight causes the control Point to have no effect; Conic is identical to a line segment from start Point to end point. If Weight is less than one, Conic follows an elliptical arc. If Weight is exactly one, then Conic is identical to Quad; Conic follows a parabolic arc. If Weight is greater than one, Conic follows a hyperbolic arc. If Weight is infinity, Conic is identical to two line segments, connecting start Point to control Point, and control Point to end Point.

Example

Example Output

move {0, 0},
quad {0, 0}, {20, 30}, {50, 60},
done

If weight is less than one, Conic is an elliptical segment.

Example

Example Output

move {0, 0},
conic {0, 0}, {20, 0}, {20, 20}, weight = 0.707107
done

If weight is greater than one, Conic is a hyperbolic segment. As weight gets large, a hyperbolic segment can be approximated by straight lines connecting the control Point with the end Points.

Example

Example Output

move {0, 0},
line {0, 0}, {20, 0},
line {20, 0}, {20, 20},
done


Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.

If w is finite and not one, appends kConic_Verb to verb array; and (x1, y1), (x2, y2) to SkPoint array; and w to conic weights.

If w is one, appends kQuad_Verb to verb array, and (x1, y1), (x2, y2) to SkPoint array.

If w is not finite, appends kLine_Verb twice to verb array, and (x1, y1), (x2, y2) to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

rConicTo arcTo addArc quadTo


Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.

If w is finite and not one, appends kConic_Verb to verb array; and SkPoint p1, p2 to SkPoint array; and w to conic weights.

If w is one, appends kQuad_Verb to verb array, and SkPoint p1, p2 to SkPoint array.

If w is not finite, appends kLine_Verb twice to verb array, and SkPoint p1, p2 to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

rConicTo arcTo addArc quadTo


Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.

If w is finite and not one, next appends kConic_Verb to verb array, and w is recorded as conic weight; otherwise, if w is one, appends kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb twice to verb array.

In all cases appends SkPoint control and end to SkPoint array. control is last point plus vector (dx1, dy1). end is last point plus vector (dx2, dy2).

Function name stands for “relative conic to”.

Parameters

Return Value

reference to SkPath

Example

See Also

conicTo arcTo addArc quadTo


Cubic describes a Bezier_Curve segment described by a third-order polynomial. Cubic begins at a start Point, curving towards the first control Point; and curves from the end Point towards the second control Point.

Example


Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kCubic_Verb to verb array; and (x1, y1), (x2, y2), (x3, y3) to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo rCubicTo quadTo


Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at SkPoint p3. If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kCubic_Verb to verb array; and SkPoint p1, p2, p3 to SkPoint array.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo rCubicTo quadTo


Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3). If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kCubic_Verb to verb array; and appends cubic control and cubic end to SkPoint array. Cubic control is last point plus vector (dx1, dy1). Cubic end is last point plus vector (dx2, dy2). Function name stands for “relative cubic to”.

Parameters

Return Value

reference to SkPath

Example

See Also

Contour moveTo cubicTo quadTo


Arc can be constructed in a number of ways. Arc may be described by part of Oval and angles, by start point and end point, and by radius and tangent lines. Each construction has advantages, and some constructions correspond to Arc drawing in graphics standards.

All Arc draws are implemented by one or more Conic draws. When Conic_Weight is less than one, Conic describes an Arc of some Oval or Circle.

CirclearcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo) describes Arc as a piece of Oval, beginning at start angle, sweeping clockwise or counterclockwise, which may continue Contour or start a new one. This construction is similar to PostScript and HTML_Canvas arcs. Variation addArc always starts new Contour. SkCanvas::drawArc draws without requiring Path.

PatharcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius) describes Arc as tangent to the line segment from last Point added to Path to (x1, y1); and tangent to the line segment from (x1, y1) to (x2, y2). This construction is similar to PostScript and HTML_Canvas arcs.

arcsarcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep, SkScalar x, SkScalar y) describes Arc as part of Oval with radii (rx, ry), beginning at last Point added to Path and ending at (x, y). More than one Arc satisfies this criteria, so additional values choose a single solution. This construction is similar to SVG arcs.

conicTo describes Arc of less than 180 degrees as a pair of tangent lines and Conic_Weight. conicTo can represent any Arc with a sweep less than 180 degrees at any rotation. All arcTo constructions are converted to Conic data when added to Path.

Arc

Example

In the example above:


Appends arc to SkPath. 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 connecting SkPath last SkPoint to initial arc SkPoint if forceMoveTo is false and SkPath is not empty. Otherwise, added contour begins with first point of arc. Angles greater than -360 and less than 360 are treated modulo 360.

Parameters

Return Value

reference to SkPath

Example

See Also

addArc SkCanvas::drawArc conicTo


Appends arc to SkPath, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last SkPath 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.

Parameters

Return Value

reference to SkPath

Example

Example

Example

Example Output

move to (156,20)
line (156,20),(79.2893,20)
conic (79.2893,20),(200,20),(114.645,105.355) weight 0.382683

See Also

conicTo


Appends arc to SkPath, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last SkPath point to p1, and tangent from p1 to p2. Arc is part of circle sized to radius, positioned so it touches both tangent lines.

If last SkPath SkPoint does not start arc, arcTo() appends connecting line to SkPath. The length of vector from p1 to p2 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 SkPath SkPoint to p1.

arcTo() appends at most one line and one conic. arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.

Parameters

Return Value

reference to SkPath

Example

Example Output

move to (156,20)
line (156,20),(200,20)

See Also

conicTo


Four axis-aligned Ovals with the same height and width intersect a pair of Points. ArcSize and Direction select one of the four Ovals, by choosing the larger or smaller arc between the Points; and by choosing the arc Direction, clockwise or counterclockwise.

Constants

Example

See Also

arcTo Direction


Appends arc to SkPath. 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 last SkPath SkPoint 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 last SkPath SkPoint equals (x, y). arcTo() scales radii (rx, ry) to fit last SkPath SkPoint 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.

Parameters

Return Value

reference to SkPath

Example

See Also

rArcTo ArcSize Direction


Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves from last SkPath SkPoint to (xy.fX, xy.fY), 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 xy if either radii are zero, or if last SkPath SkPoint equals (xy.fX, xy.fY). arcTo() scales radii r to fit last SkPath SkPoint and xy 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 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.

Parameters

Return Value

reference to SkPath

Example

See Also

rArcTo ArcSize Direction


Appends Arc to Path, relative to last Path 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 last Path Point to relative end Point (dx, dy), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. If Path is empty, the start Arc Point is (0, 0).

Arc sweep is always less than 360 degrees. arcTo appends Line to end Point if either radii are zero, or if last Path Point equals end Point. arcTo scales radii (rx, ry) to fit last Path Point and end Point 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 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.

Parameters

Return Value

reference to Path

Example

See Also

arcTo ArcSize Direction


Appends kClose_Verb to SkPath. A closed contour connects the first and last SkPoint with line, forming a continuous loop. Open and closed contour draw the same with SkPaint::kFill_Style. With SkPaint::kStroke_Style, open contour draws SkPaint::Cap at contour start and end; closed contour draws SkPaint::Join at contour start and end.

close() has no effect if SkPath is empty or last SkPath SkPath::Verb is kClose_Verb.

Return Value

reference to SkPath

Example

See Also


Returns true if fill is inverted and Path with fill represents area outside of its geometric bounds.

FillTypeis inverse
kWinding_FillTypefalse
kEvenOdd_FillTypefalse
kInverseWinding_FillTypetrue
kInverseEvenOdd_FillTypetrue

Parameters

Return Value

true if Path fills outside its bounds

Example

Example Output

IsInverseFillType(kWinding_FillType) == false
IsInverseFillType(kEvenOdd_FillType) == false
IsInverseFillType(kInverseWinding_FillType) == true
IsInverseFillType(kInverseEvenOdd_FillType) == true

See Also

FillType getFillType setFillType ConvertToNonInverseFillType


Returns equivalent Fill_Type representing Path fill inside its bounds.

FillTypeinside FillType
kWinding_FillTypekWinding_FillType
kEvenOdd_FillTypekEvenOdd_FillType
kInverseWinding_FillTypekWinding_FillType
kInverseEvenOdd_FillTypekEvenOdd_FillType

Parameters

Return Value

fill, or kWinding_FillType or kEvenOdd_FillType if fill is inverted

Example

Example Output

ConvertToNonInverseFillType(kWinding_FillType) == kWinding_FillType
ConvertToNonInverseFillType(kEvenOdd_FillType) == kEvenOdd_FillType
ConvertToNonInverseFillType(kInverseWinding_FillType) == kWinding_FillType
ConvertToNonInverseFillType(kInverseEvenOdd_FillType) == kEvenOdd_FillType

See Also

FillType getFillType setFillType IsInverseFillType


Approximates Conic with Quad array. Conic is constructed from start Point p0, control Point p1, end Point p2, and weight w. Quad array is stored in pts; this storage is supplied by caller. Maximum Quad count is 2 to the pow2. Every third point in array shares last Point of previous Quad and first Point of next Quad. Maximum pts storage size is given by: (1 + 2 * (1 << pow2)) * sizeof(SkPoint).

Returns Quad count used the approximation, which may be smaller than the number requested.

Conic_Weight determines the amount of influence Conic control point has on the curve. w less than one represents an elliptical section. w greater than one represents a hyperbolic section. w equal to one represents a parabolic section.

Two Quad curves are sufficient to approximate an elliptical Conic with a sweep of up to 90 degrees; in this case, set pow2 to one.

Parameters

Return Value

number of Quad curves written to pts

Example

See Also

Conic Quad


Returns true if SkPath is equivalent to SkRect when filled. If false: rect, isClosed, and direction are unchanged. If true: rect, isClosed, and direction are written to if not nullptr.

rect may be smaller than the SkPath bounds. SkPath bounds may include kMove_Verb points that do not alter the area drawn by the returned rect.

Parameters

Return Value

true if SkPath contains SkRect

Example

Example Output

empty is not rect
addRect is rect (10, 20, 30, 40); is closed; direction CW
moveTo is rect (10, 20, 30, 40); is closed; direction CW
lineTo is not rect
addPoly is rect (0, 0, 80, 80); is not closed; direction CCW

See Also

computeTightBounds conservativelyContainsRect getBounds isConvex isLastContourClosed isNestedFillRects


Returns true if SkPath is equivalent to nested SkRect pair when filled. If false, rect and dirs are unchanged. If true, rect and dirs are written to if not nullptr: setting rect[0] to outer SkRect, and rect[1] to inner SkRect; setting dirs[0] to SkPath::Direction of outer SkRect, and dirs[1] to SkPath::Direction of inner SkRect.

Parameters

Return Value

true if SkPath contains nested SkRect pair

Example

Example Output

outer (7.5, 17.5, 32.5, 42.5); direction CW
inner (12.5, 22.5, 27.5, 37.5); direction CCW

See Also

computeTightBounds conservativelyContainsRect getBounds isConvex isLastContourClosed isRect


Adds SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of SkRect; followed by top-right, bottom-right, and bottom-left if dir is kCW_Direction; or followed by bottom-left, bottom-right, and top-right if dir is kCCW_Direction.

Parameters

Return Value

reference to SkPath

Example

See Also

SkCanvas::drawRect Direction


Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb. If dir is kCW_Direction, Rect corners are added clockwise; if dir is kCCW_Direction, Rect corners are added counterclockwise. start determines the first corner added.

startfirst corner
0top-left
1top-right
2bottom-right
3bottom-left

Parameters

Return Value

reference to Path

Example

See Also

SkCanvas::drawRect Direction


Adds SkRect (left, top, right, bottom) to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of SkRect; followed by top-right, bottom-right, and bottom-left if dir is kCW_Direction; or followed by bottom-left, bottom-right, and top-right if dir is kCCW_Direction.

Parameters

Return Value

reference to SkPath

Example

See Also

SkCanvas::drawRect Direction


Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. Oval is upright ellipse bounded by SkRect 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.

Parameters

Return Value

reference to SkPath

Example

See Also

SkCanvas::drawOval Direction Oval


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 start and continues clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.

startPoint
0oval.centerX(), oval.fTop
1oval.fRight, oval.centerY()
2oval.centerX(), oval.fBottom
3oval.fLeft, oval.centerY()

Parameters

Return Value

reference to Path

Example

See Also

SkCanvas::drawOval Direction Oval


Adds Circle centered at (x, y) of size radius to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.

Has no effect if radius is zero or negative.

Parameters

Return Value

reference to Path

Example

See Also

SkCanvas::drawCircle Direction Circle


Appends arc to SkPath, 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 <= -360, or sweepAngle >= 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.

Parameters

Return Value

reference to SkPath

Example

See Also

Arc arcTo SkCanvas::drawArc


Appends SkRRect to SkPath, creating a new closed contour. SkRRect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If dir is kCW_Direction, SkRRect starts at top-left of the lower-left corner and winds clockwise. If dir is kCCW_Direction, SkRRect 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, addRoundRect() appends SkRect rect to SkPath.

After appending, SkPath may be empty, or may contain: SkRect, oval, or SkRRect.

Parameters

Return Value

reference to SkPath

Example

See Also

addRRect SkCanvas::drawRoundRect


Appends Round_Rect to Path, creating a new closed Contour. Round_Rect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii from the array.

radii indexlocation
0x-axis radius of top-left corner
1y-axis radius of top-left corner
2x-axis radius of top-right corner
3y-axis radius of top-right corner
4x-axis radius of bottom-right corner
5y-axis radius of bottom-right corner
6x-axis radius of bottom-left corner
7y-axis radius of bottom-left corner

If dir is kCW_Direction, Round_Rect starts at top-left of the lower-left corner and winds clockwise. If dir is kCCW_Direction, Round_Rect starts at the bottom-left of the upper-left corner and winds counterclockwise.

If both radii on any side of rect exceed its length, all radii are scaled uniformly until the corners fit. If either radius of a corner is less than or equal to zero, both are treated as zero.

After appending, Path may be empty, or may contain: Rect, Oval, or Round_Rect.

Parameters

Return Value

reference to Path

Example

See Also

addRRect SkCanvas::drawRoundRect


Adds rrect to SkPath, creating a new closed contour. If dir is kCW_Direction, rrect starts at top-left of the lower-left corner and winds clockwise. If dir is kCCW_Direction, rrect starts at the bottom-left of the upper-left corner and winds counterclockwise.

After appending, SkPath may be empty, or may contain: SkRect, oval, or SkRRect.

Parameters

Return Value

reference to SkPath

Example

See Also

addRoundRect SkCanvas::drawRRect


Adds rrect to Path, creating a new closed Contour. If dir is kCW_Direction, rrect winds clockwise; if dir is kCCW_Direction, rrect winds counterclockwise. start determines the first point of rrect to add.

startlocation
0right of top-left corner
1left of top-right corner
2bottom of top-right corner
3top of bottom-right corner
4left of bottom-right corner
5right of bottom-left corner
6top of bottom-left corner
7bottom of top-left corner

After appending, Path may be empty, or may contain: Rect, Oval, or Round_Rect.

Parameters

Return Value

reference to Path

Example

See Also

addRoundRect SkCanvas::drawRRect


Adds contour created from line array, adding (count - 1) line segments. Contour added starts at pts[0], then adds a line for every additional SkPoint in pts array. If close is true, appends kClose_Verb to SkPath, connecting pts[count - 1] and pts[0].

If count is zero, append kMove_Verb to path. Has no effect if count is less than one.

Parameters

Return Value

reference to SkPath

Example

See Also

SkCanvas::drawPoints


Adds contour created from list. Contour added starts at list[0], then adds a line for every additional SkPoint in list. If close is true, appends kClose_Verb to SkPath, connecting last and first SkPoint in list.

If list is empty, append kMove_Verb to path.

Parameters

Return Value

reference to SkPath

Example

See Also

SkCanvas::drawPoints


AddPathMode chooses how addPath appends. Adding one Path to another can extend the last Contour or start a new Contour.

Constants

Example

See Also

addPath reverseAddPath


Appends src to SkPath, offset by (dx, dy).

If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, SkPoint, and conic weights.

Parameters

Return Value

reference to SkPath

Example

See Also

AddPathMode offset reverseAddPath


Appends src to SkPath.

If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, SkPoint, and conic weights.

Parameters

Return Value

reference to SkPath

Example

See Also

AddPathMode reverseAddPath


Appends src to SkPath, transformed by matrix. Transformed curves may have different verbs, SkPoint, and conic weights.

If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, SkPoint, and conic weights.

Parameters

Return Value

reference to SkPath

Example

See Also

AddPathMode transform offset reverseAddPath


Appends src to SkPath, from back to front. Reversed src always appends a new contour to SkPath.

Parameters

Return Value

reference to SkPath

Example

See Also

AddPathMode transform offset addPath


Offsets SkPoint array by (dx, dy). Offset SkPath replaces dst. If dst is nullptr, SkPath is replaced by offset data.

Parameters

Example

See Also

addPath transform


Offsets SkPoint array by (dx, dy). SkPath is replaced by offset data.

Parameters

Example

See Also

addPath transform SkCanvas::translate()


Transforms verb array, SkPoint array, and weight by matrix. transform may change verbs and increase their number. Transformed SkPath replaces dst; if dst is nullptr, original data is replaced.

Parameters

Example

See Also

addPath offset SkCanvas::concat() SkMatrix


Transforms verb array, SkPoint array, and weight by matrix. transform may change verbs and increase their number. SkPath is replaced by transformed data.

Parameters

Example

See Also

addPath offset SkCanvas::concat() SkMatrix

Path is defined cumulatively, often by adding a segment to the end of last Contour. Last_Point of Contour is shared as first Point of added Line or Curve. Last_Point can be read and written directly with getLastPt and setLastPt.


Returns last point on SkPath in lastPt. Returns false if SkPoint array is empty, storing (0, 0) if lastPt is not nullptr.

Parameters

Return Value

true if SkPoint array contains one or more SkPoint

Example

Example Output

last point: 35.2786, 52.9772

See Also

setLastPt


Sets last point to (x, y). If SkPoint array is empty, append kMove_Verb to verb array and append (x, y) to SkPoint array.

Parameters

Example

See Also

getLastPt


Sets the last point on the path. If SkPoint array is empty, append kMove_Verb to verb array and append p to SkPoint array.

Parameters

Example

See Also

getLastPt


SegmentMask constants correspond to each drawing Verb type in Path; for instance, if Path only contains Lines, only the kLine_SegmentMask bit is set.

Constants

Example

Example Output

Path kConic_SegmentMask is clear
Path kQuad_SegmentMask is set

See Also

getSegmentMasks Verb


Returns a mask, where each set bit corresponds to a SegmentMask constant if SkPath contains one or more verbs of that type. Returns zero if SkPath contains no lines, or curves: quads, conics, or cubics.

getSegmentMasks() returns a cached result; it is very fast.

Return Value

SegmentMask bits or zero

Example

Example Output

mask quad set

See Also

getSegmentMasks Verb


Returns true if the point (x, y) is contained by Path, taking into account FillType.

FillTypecontains() returns true if Point is enclosed by
kWinding_FillTypea non-zero sum of Contour Directions.
kEvenOdd_FillTypean odd number of Contours.
kInverseWinding_FillTypea zero sum of Contour Directions.
kInverseEvenOdd_FillTypeand even number of Contours.

Parameters

Return Value

true if Point is in Path

Example

See Also

conservativelyContainsRect Fill_Type Op


Writes text representation of SkPath to stream. If stream is nullptr, writes to standard output. Set forceClose to true to get edges used to fill SkPath. Set dumpAsHex true to generate exact binary representations of floating point numbers used in SkPoint array and conic weights.

Parameters

Example

Example Output

path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0, 0);
path.quadTo(20, 30, 40, 50);
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000));  // 0, 0
path.quadTo(SkBits2Float(0x41a00000), SkBits2Float(0x41f00000), SkBits2Float(0x42200000), SkBits2Float(0x42480000));  // 20, 30, 40, 50
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0, 0);
path.quadTo(20, 30, 40, 50);
path.lineTo(0, 0);
path.close();
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000));  // 0, 0
path.quadTo(SkBits2Float(0x41a00000), SkBits2Float(0x41f00000), SkBits2Float(0x42200000), SkBits2Float(0x42480000));  // 20, 30, 40, 50
path.lineTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000));  // 0, 0
path.close();

See Also

dumpHex SkRect::dump() SkRRect::dump() SkPathMeasure::dump()


Writes text representation of SkPath to standard output. The representation may be directly compiled as C++ code. Floating point values are written with limited precision; it may not be possible to reconstruct original SkPath from output.

Example

Example Output

path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0, 0);
path.lineTo(0.857143f, 0.666667f);
path is not equal to copy

See Also

dumpHex SkRect::dump() SkRRect::dump() SkPathMeasure::dump() writeToMemory


Writes text representation of Path to standard output. The representation may be directly compiled as C++ code. Floating point values are written in hexadecimal to preserve their exact bit pattern. The output reconstructs the original Path.

Use instead of dump() when submitting bug reports against Skia .

Example

Example Output

path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000));  // 0, 0
path.lineTo(SkBits2Float(0x3f5b6db7), SkBits2Float(0x3f2aaaab));  // 0.857143f, 0.666667f
path is equal to copy

See Also

dump SkRect::dumpHex SkRRect::dumpHex writeToMemory


Writes SkPath to buffer, returning the number of bytes written. Pass nullptr to obtain the storage size.

Writes SkPath::FillType, verb array, SkPoint array, conic weight, and additionally writes computed information like SkPath::Convexity and bounds.

Use only be used in concert with readFromMemory(); the format used for SkPath in memory is not guaranteed.

Parameters

Return Value

size of storage required for SkPath; always a multiple of 4

Example

Example Output

path is equal to copy

See Also

serialize readFromMemory dump dumpHex


Writes SkPath to buffer, returning the buffer written to, wrapped in SkData.

serialize() writes SkPath::FillType, verb array, SkPoint array, conic weight, and additionally writes computed information like SkPath::Convexity and bounds.

serialize() should only be used in concert with readFromMemory(). The format used for SkPath in memory is not guaranteed.

Return Value

SkPath data wrapped in SkData buffer

Example

Example Output

path is equal to copy

See Also

writeToMemory readFromMemory dump dumpHex


Initializes SkPath from buffer of size length. Returns zero if the buffer is data is inconsistent, or the length is too small.

Reads SkPath::FillType, verb array, SkPoint array, conic weight, and additionally reads computed information like SkPath::Convexity and bounds.

Used only in concert with writeToMemory(); the format used for SkPath in memory is not guaranteed.

Parameters

Return Value

number of bytes read, or zero on failure

Example

Example Output

length = 32; returned by readFromMemory = 0
length = 40; returned by readFromMemory = 36

See Also

writeToMemory

Generation_ID provides a quick way to check if Verb_Array, Point_Array, or Conic_Weight has changed. Generation_ID is not a hash; identical Paths will not necessarily have matching Generation_IDs.

Empty Paths have a Generation_ID of one.


(See Skia bug 1762.) Returns a non-zero, globally unique value. A different value is returned if verb array, SkPoint array, or conic weight changes.

Setting SkPath::FillType does not change generation identifier.

Each time the path is modified, a different generation identifier will be returned. SkPath::FillType does affect generation identifier on Android framework.

Return Value

non-zero, globally unique value

Example

Example Output

empty genID = 1
1st lineTo genID = 2
empty genID = 1
2nd lineTo genID = 3

See Also

operator==(const SkPath& a, const SkPath& b)


Returns if SkPath data is consistent. Corrupt SkPath data is detected if internal values are out of range or internal storage does not match array dimensions.

Return Value

true if SkPath data is consistent


Iterates through Verb_Array, and associated Point_Array and Conic_Weight. Provides options to treat open Contours as closed, and to ignore degenerate data.

Example

See Also

RawIter


Initializes SkPath::Iter with an empty SkPath. next() on SkPath::Iter returns kDone_Verb. Call setPath to initialize SkPath::Iter at a later time.

Return Value

SkPath::Iter of empty SkPath

Example

Example Output

iter is done
iter is done

See Also

setPath


Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path. If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each open contour. path is not altered.

Parameters

Return Value

SkPath::Iter of path

Example

Example Output

open:
kMove_Verb {0, 0},
kQuad_Verb {0, 0}, {10, 20}, {30, 40},
kDone_Verb
closed:
kMove_Verb {0, 0},
kQuad_Verb {0, 0}, {10, 20}, {30, 40},
kLine_Verb {30, 40}, {0, 0},
kClose_Verb {0, 0},
kDone_Verb

See Also

setPath


Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path. If forceClose is true, SkPath::Iter will add kLine_Verb and kClose_Verb after each open contour. path is not altered.

Parameters

Example

Example Output

quad open:
kMove_Verb {0, 0},
kQuad_Verb {0, 0}, {10, 20}, {30, 40},
kDone_Verb
conic closed:
kMove_Verb {0, 0},
kConic_Verb {0, 0}, {1, 2}, {3, 4}, weight = 0.5
kLine_Verb {3, 4}, {0, 0},
kClose_Verb {0, 0},
kDone_Verb

See Also

Iter(const SkPath& path, bool forceClose)


Returns next SkPath::Verb in verb array, and advances SkPath::Iter. When verb array is exhausted, returns kDone_Verb.

Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.

If doConsumeDegenerates is true, skip consecutive kMove_Verb entries, returning only the last in the series; and skip very small lines, quads, and conics; and skip kClose_Verb following kMove_Verb. if doConsumeDegenerates is true and exact is true, only skip lines, quads, and conics with zero lengths.

Parameters

Return Value

next SkPath::Verb from verb array

Example

skip degenerate if exact skips the same as skip degenerate, but shows the very small Line.

skip none shows all of the Verbs and Points in Path.

Example Output

skip degenerate:
kMove_Verb {20, 20},
kQuad_Verb {20, 20}, {10, 20}, {30, 40},
kDone_Verb
skip degenerate if exact:
kMove_Verb {20, 20},
kQuad_Verb {20, 20}, {10, 20}, {30, 40},
kMove_Verb {30, 30},
kLine_Verb {30, 30}, {30.00001, 30},
kDone_Verb
skip none:
kMove_Verb {10, 10},
kMove_Verb {20, 20},
kQuad_Verb {20, 20}, {10, 20}, {30, 40},
kMove_Verb {1, 1},
kClose_Verb {1, 1},
kMove_Verb {30, 30},
kLine_Verb {30, 30}, {30, 30},
kMove_Verb {30, 30},
kLine_Verb {30, 30}, {30.00001, 30},
kDone_Verb

See Also

Verb IsLineDegenerate IsCubicDegenerate IsQuadDegenerate


Returns conic weight if next() returned kConic_Verb.

If next() has not been called, or next() did not return kConic_Verb, result is undefined.

Return Value

conic weight for conic SkPoint returned by next()

Example

Example Output

first verb is move
next verb is conic
conic points: {0,0}, {1,2}, {3,4}
conic weight: 0.5

See Also

Conic_Weight


Returns true if last kLine_Verb returned by next() was generated by kClose_Verb. When true, the end point returned by next() is also the start point of contour.

If next() has not been called, or next() did not return kLine_Verb, result is undefined.

Return Value

true if last kLine_Verb was generated by kClose_Verb

Example

Example Output

1st verb is move
moveTo point: {6,7}
2nd verb is conic
3rd verb is line
line points: {3,4}, {6,7}
line generated by close
4th verb is close

See Also

close()


Returns true if subsequent calls to next() return kClose_Verb before returning kMove_Verb. if true, contour SkPath::Iter is processing may end with kClose_Verb, or SkPath::Iter may have been initialized with force close set to true.

Return Value

true if contour is closed

Example

Example Output

without close(), forceClose is false: isClosedContour returns false
with close(),    forceClose is false: isClosedContour returns true
without close(), forceClose is true : isClosedContour returns true
with close(),    forceClose is true : isClosedContour returns true

See Also

Iter(const SkPath& path, bool forceClose)


Iterates through Verb_Array, and associated Point_Array and Conic_Weight. Verb_Array, Point_Array, and Conic_Weight are returned unaltered.


Initializes RawIter with an empty SkPath. next() on RawIter returns kDone_Verb. Call setPath to initialize SkPath::Iter at a later time.

Return Value

RawIter of empty SkPath


Sets RawIter to return elements of verb array, SkPoint array, and conic weight in path.

Parameters

Return Value

RawIter of path


Sets SkPath::Iter to return elements of verb array, SkPoint array, and conic weight in path.

Parameters


Returns next SkPath::Verb in verb array, and advances RawIter. When verb array is exhausted, returns kDone_Verb. Zero to four SkPoint are stored in pts, depending on the returned SkPath::Verb.

Parameters

Return Value

next SkPath::Verb from verb array

Example

Example Output

kMove_Verb {50, 60},
kQuad_Verb {50, 60}, {10, 20}, {30, 40},
kClose_Verb {50, 60},
kMove_Verb {50, 60},
kLine_Verb {50, 60}, {30, 30},
kConic_Verb {30, 30}, {1, 2}, {3, 4}, weight = 0.5
kCubic_Verb {3, 4}, {-1, -2}, {-3, -4}, {-5, -6},
kDone_Verb

See Also

peek()


Returns next SkPath::Verb, but does not advance RawIter.

Return Value

next SkPath::Verb from verb array

Example

Example Output

#Volatile
peek Move == verb Move
peek Quad == verb Quad
peek Conic == verb Conic
peek Cubic == verb Cubic
peek Done == verb Done
peek Done == verb Done

See Also

next


Returns conic weight if next() returned kConic_Verb.

If next() has not been called, or next() did not return kConic_Verb, result is undefined.

Return Value

conic weight for conic SkPoint returned by next()

Example

Example Output

first verb is move
next verb is conic
conic points: {0,0}, {1,2}, {3,4}
conic weight: 0.5

See Also

Conic_Weight