SkPath Reference

Path

Path contains Lines and Curves which can be stroked or filled. Contour is composed of a series of connected Lines and Curves. Path may contain zero, one, or more Contours. Each Line and Curve are described by Verb, Points, and optional Conic Weight.

Each pair of connected Lines and Curves share common Point; for instance, Path containing two connected Lines are described the Verb sequence: SkPath::kMove Verb, SkPath::kLine Verb, SkPath::kLine Verb; and a Point sequence with three entries, sharing the middle entry as the end of the first Line and the start of the second Line.

Path components Arc, Rect, Round Rect, Circle, and Oval are composed of Lines and Curves with as many Verbs and Points required for an exact description. Once added to Path, these components may lose their identity; although Path can be inspected to determine if it describes a single Rect, Oval, Round Rect, and so on.

Example

Path contains a Fill Type which determines whether overlapping Contours form fills or holes. Fill Type also determines whether area inside or outside Lines and Curves is filled.

Example

Path contents are never shared. Copying Path by value effectively creates a new Path independent of the original. Internally, the copy does not duplicate its contents until it is edited, to reduce memory use and improve performance.

Contour

Contour contains one or more Verbs, and as many Points as are required to satisfy Verb Array. First Verb in Path is always SkPath::kMove Verb; each SkPath::kMove Verb that follows starts a new Contour.

Example

If final Verb in Contour is SkPath::kClose Verb, Line connects Last Point in Contour with first Point. A closed Contour, stroked, draws Paint Stroke Join at Last Point and first Point. Without SkPath::kClose Verb as final Verb, Last Point and first Point are not connected; Contour remains open. An open Contour, stroked, draws Paint Stroke Cap at Last Point and first Point.

Example

Contour Zero Length

Contour length is distance traveled from first Point to Last Point, plus, if Contour is closed, distance from Last Point to first Point. Even if Contour length is zero, stroked Lines are drawn if Paint Stroke Cap makes them visible.

Example

Class SkPath

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.

Overview

Related Function

SkPath global, struct, and class related member functions share a topic.

Constant

SkPath related constants are defined by enum, enum class, #define, const, and constexpr.

Class

SkPath uses C++ classes to declare the public data structures and interfaces.

Constructor

SkPath can be constructed or initialized by these functions, including C++ class constructors.

Operator

SkPath operators inline class member functions with arithmetic equivalents.

Member Function

SkPath member functions read and modify the structure properties.

Verb

Enum SkPath::Verb

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

Enum SkPath::Direction

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[2][3][4][5] rArcTo isRect isNestedFillRects addRect[2][3] addOval[2]

SkPath

By default, Path has no Verbs, no Points, and no Weights. Fill Type is set to kWinding FillType.

Return Value

empty Path

Example

Example Output

path is empty

See Also

reset rewind


SkPath

Copy constructor makes two paths identical by value. Internally, path and the returned result share pointer values. The underlying Verb Array, Point Array and Weights are copied when modified.

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

Parameters

Return Value

copy of Path

Example

Example Output

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

See Also

operator=(const SkPath& path)


~SkPath

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

Example

See Also

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


operator=

Path assignment makes two paths identical by value. Internally, assignment shares pointer values. The underlying Verb Array, Point Array and Weights are copied when modified.

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

Parameters

Return Value

Path 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)


operator==

Compares a and b; returns true if Fill Type, Verb Array, Point Array, and Weights are equivalent.

Parameters

Return Value

true if Path pair are equivalent

Example

Example Output

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


operator!=

Compares a and b; returns true if Fill Type, Verb Array, Point Array, and Weights are not equivalent.

Parameters

Return Value

true if Path pair are not equivalent

Example

Example Output

empty one == two
addRect one == two
setConvexity one == two
convexity !=


Property

isInterpolatable

Return true if Paths contain equal Verbs and equal Weights. If Paths 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 Paths containing Conics with different Conic Weight values.

Parameters

Return Value

true if Paths Verb Array and Weights are equivalent

Example

Example Output

paths are interpolatable

See Also

isInterpolatable


Interpolate

interpolate

Interpolate 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


unique

Deprecated.

soonOnly valid for Android framework.


Fill Type

Enum SkPath::FillType

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

getFillType

Returns FillType, the rule used to fill Path. FillType of a new Path 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


setFillType

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

Parameters

Example

See Also

FillType getFillType toggleInverseFillType


isInverseFillType

Returns if FillType describes area outside Path 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


toggleInverseFillType

Replace 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


Convexity

Enum SkPath::Convexity

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

getConvexity

Computes Convexity if required, and returns stored value. Convexity is computed if stored value is kUnknown Convexity, or if Path has been altered since Convexity was computed or set.

Return Value

computed or stored Convexity

Example

See Also

Convexity Contour Direction getConvexityOrUnknown setConvexity isConvex


getConvexityOrUnknown

Returns last computed Convexity, or kUnknown Convexity if Path has been altered since Convexity was computed or set.

Return Value

stored Convexity

Example

See Also

Convexity Contour Direction getConvexity setConvexity isConvex


setConvexity

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 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


isConvex

Computes 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, Convexity is not recomputed.

Return Value

true if Convexity stored or computed is kConvex Convexity

Example

See Also

Convexity Contour Direction getConvexity getConvexityOrUnknown setConvexity


isOval

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 Path is recognized as an oval or circle

Example

See Also

Oval addCircle addOval[2]


isRRect

Returns true if this path is recognized as a SkRRect (but not an oval/circle or rect).

rrect receives bounds of Round Rect.

rrect is unmodified if Round Rect is not found.

Parameters

Return Value

true if Path contains only Round Rect

Example

See Also

Round Rect addRoundRect[2] addRRect[2]


reset

Sets Path to its initial state. Removes Verb Array, Point Array, and Weights, and sets FillType to kWinding FillType. Internal storage associated with Path is released.

Example

See Also

rewind


rewind

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 with Path is retained.

Use rewind instead of reset if Path storage will be reused and performance is critical.

Example

See Also

reset


isEmpty

Empty Path may have FillType but has no SkPoint, Verb, or Conic Weight. SkPath() constructs empty Path; reset and (rewind) make Path empty.

Return Value

true if the path contains no 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


isLastContourClosed

Contour is closed if Path Verb array was last modified by close. When stroked, closed Contour draws Paint Stroke Join instead of Paint Stroke Cap at first and last Point.

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


isFinite

Returns true for finite Point array values between negative SK ScalarMax and positive SK ScalarMax. Returns false for any Point array value of SK ScalarInfinity, SK ScalarNegativeInfinity, or SK ScalarNaN.

Return Value

true if all Point values are finite

Example

Example Output

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

See Also

SkScalar


isVolatile

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

Return Value

true if caller will alter Path after drawing

Example

Example Output

volatile by default is false

See Also

setIsVolatile


Volatile

setIsVolatile

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

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

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

Raster Surface Path draws are affected by volatile for some shadows. GPU Surface Path draws are affected by volatile for some shadows and concave geometries.

Parameters

Example

See Also

isVolatile


IsLineDegenerate

Test if Line between Point 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


IsQuadDegenerate

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

Parameters

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


IsCubicDegenerate

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

Parameters

Return Value

true if Cubic is degenerate; its length is effectively zero

Example

Example Output

0.00024414062 is degenerate
0.00024414065 is length


isLine

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

Parameters

Return Value

true if Path 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

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: Verb::kMoveTo, Verb::kLineTo, Verb::kQuadTo; 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.

getPoints

Returns number of points in Path. 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

Path Point 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


countPoints

Returns the number of points in Path. Point count is initially zero.

Return Value

Path Point 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


getPoint

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

Parameters

Return Value

Point array value or (0, 0)

Example

Example Output

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

See Also

countPoints getPoints


Verb Array

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.

countVerbs

Returns the number of Verbs: kMove Verb, kLine Verb, kQuad Verb, kConic Verb, kCubic Verb, and kClose Verb; added to Path.

Return Value

length of Verb Array

Example

Example Output

empty verb count: 0
round rect verb count: 10

See Also

getVerbs Iter RawIter


getVerbs

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


swap

Exchanges the Verb Array, Point Array, Weights, and Fill Type 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). Paths 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)


getBounds

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

Rect returned includes all Points added to Path, including Points associated with kMove Verb that define empty Contours.

Return Value

bounds of all Points in Point 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


Utility

updateBoundsCache

Update internal bounds so that subsequent calls to getBounds are instantaneous. Unaltered copies of Path may also access cached bounds through getBounds.

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

Call to prepare Path 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


computeTightBounds

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

Includes Points associated with kMove Verb that define empty Contours.

Behaves identically to getBounds when Path contains only lines. If Path 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 Path

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


conservativelyContainsRect

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

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

Parameters

Return Value

true if rect is contained

Example

See Also

contains Op Rect Convexity


incReserve

grows Path Verb Array and Point Array to contain extraPtCount additional Points. May improve performance and use less memory by reducing the number and size of allocations when creating Path.

Parameters

Example

See Also

Point Array


Build

moveTo

Adds beginning of Contour at Point (x, y).

Parameters

Example

See Also

Contour lineTo[2] rMoveTo quadTo[2] conicTo[2] cubicTo[2] close


Adds beginning of Contour at Point p.

Parameters

Example

See Also

Contour lineTo[2] rMoveTo quadTo[2] conicTo[2] cubicTo[2] close


rMoveTo

Adds beginning of Contour relative to Last Point. If Path 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

Example

See Also

Contour lineTo[2] moveTo[2] quadTo[2] conicTo[2] cubicTo[2] close


lineTo

Adds Line from Last Point to (x, y). If Path is empty, or last 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 Point Array, if needed. lineTo then appends kLine Verb to Verb Array and (x, y) to Point Array.

Parameters

Example

See Also

Contour moveTo[2] rLineTo addRect[2][3]


Adds Line from Last Point to Point p. If Path is empty, or last 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 Point Array, if needed. lineTo then appends kLine Verb to Verb Array and Point p to Point Array.

Parameters

Example

See Also

Contour moveTo[2] rLineTo addRect[2][3]


rLineTo

Adds Line from Last Point to Vector (dx, dy). If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Line.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kLine Verb to Verb Array and Line end to Point Array. Line end is Last Point plus Vector (dx, dy). Function name stands for "relative line to".

Parameters

Example

See Also

Contour moveTo[2] lineTo[2] addRect[2][3]


Quad

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

quadTo

Adds Quad from Last Point towards (x1, y1), to (x2, y2). If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Quad.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kQuad Verb to Verb Array; and (x1, y1), (x2, y2) to Point Array.

Parameters

Example

See Also

Contour moveTo[2] conicTo[2] rQuadTo


Adds Quad from Last Point towards Point p1, to Point p2. If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Quad.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kQuad Verb to Verb Array; and Points p1, p2 to Point Array.

Parameters

Example

See Also

Contour moveTo[2] conicTo[2] rQuadTo


rQuadTo

Adds Quad from Last Point towards Vector (dx1, dy1), to Vector (dx2, dy2). If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Quad.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kQuad Verb to Verb Array; and appends Quad control and Quad end to Point 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

Example

See Also

Contour moveTo[2] conicTo[2] quadTo[2]


Conic

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.

Conic Weight

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

conicTo

Adds Conic from Last Point towards (x1, y1), to (x2, y2), weighted by w. If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Conic.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed.

If w is finite and not one, appends kConic Verb to Verb Array; and (x1, y1), (x2, y2) to Point Array; and w to Conic Weights.

If w is one, appends kQuad Verb to Verb Array, and (x1, y1), (x2, y2) to Point Array.

If w is not finite, appends kLine Verb twice to Verb Array, and (x1, y1), (x2, y2) to Point Array.

Parameters

Example

See Also

rConicTo arcTo[2][3][4][5] addArc quadTo[2]


Adds Conic from Last Point towards Point p1, to Point p2, weighted by w. If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Conic.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed.

If w is finite and not one, appends kConic Verb to Verb Array; and Points p1, p2 to Point Array; and w to Conic Weights.

If w is one, appends kQuad Verb to Verb Array, and Points p1, p2 to Point Array.

If w is not finite, appends kLine Verb twice to Verb Array, and Points p1, p2 to Point Array.

Parameters

Example

See Also

rConicTo arcTo[2][3][4][5] addArc quadTo[2]


rConicTo

Adds Conic from Last Point towards Vector (dx1, dy1), to Vector (dx2, dy2), weighted by w. If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Conic.

Appends kMove Verb to Verb Array and (0, 0) to Point 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 Points control and end to Point 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

Example

See Also

conicTo[2] arcTo[2][3][4][5] addArc quadTo[2]


Cubic

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

cubicTo

Adds Cubic from Last Point towards (x1, y1), then towards (x2, y2), ending at (x3, y3). If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Cubic.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kCubic Verb to Verb Array; and (x1, y1), (x2, y2), (x3, y3) to Point Array.

Parameters

Example

See Also

Contour moveTo[2] rCubicTo quadTo[2]


Adds Cubic from Last Point towards Point p1, then towards Point p2, ending at Point p3. If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Cubic.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kCubic Verb to Verb Array; and Points p1, p2, p3 to Point Array.

Parameters

Example

See Also

Contour moveTo[2] rCubicTo quadTo[2]


rCubicTo

Adds Cubic from Last Point towards Vector (dx1, dy1), then towards Vector (dx2, dy2), to Vector (dx3, dy3). If Path is empty, or last Verb is kClose Verb, Last Point is set to (0, 0) before adding Cubic.

Appends kMove Verb to Verb Array and (0, 0) to Point Array, if needed; then appends kCubic Verb to Verb Array; and appends Cubic control and Cubic end to Point 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

Example

See Also

Contour moveTo[2] cubicTo[2] quadTo[2]


Arc

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.

arcTo(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. Canvas::drawArc draws without requiring Path.

arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius) describes Arc as tangent to the line (x0, y0), (x1, y1) and tangent to the line (x1, y1), (x2, y2) where (x0, y0) is the last Point added to Path. This construction is similar to PostScript and HTML Canvas arcs.

arcTo(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.

Example

Example

arcTo

Append 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 connecting Path last Point to initial Arc Point if forceMoveTo is false and Path 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

Example

See Also

addArc SkCanvas::drawArc conicTo[2]


Append 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 last Path point (x0, y0) 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.

Example

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.

Example

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

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[2]


Append 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 last Path 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 Path Point does not start Arc, arcTo appends connecting Line to Path. 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 Path Point to p1.

arcTo appends at most one Line and one Conic. arcTo implements the functionality of PostScript Arct and HTML Canvas ArcTo.

Parameters

Example

Example Output

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

See Also

conicTo[2]


Enum SkPath::ArcSize

Four Oval parts with radii (rx, ry) start at last Path Point and ends at (x, y). ArcSize and Direction select one of the four Oval parts.

Constants

Example

See Also

arcTo[2][3][4][5] Direction

Append 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 last Path 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 last Path Point equals (x, y). arcTo scales radii (rx, ry) to fit last Path 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.

Parameters

Example

See Also

rArcTo ArcSize Direction


Append Arc to Path. 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 Path Point 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 Path Point equals (x, y). arcTo scales radii r to fit last Path Point 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

Example

See Also

rArcTo ArcSize Direction


rArcTo

Append 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 (x0, y0) to end Point:

(x0 + dx, y0 + 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

Example

See Also

arcTo[2][3][4][5] ArcSize Direction


close

Append kClose Verb to Path. A closed Contour connects the first and last Point with Line, forming a continuous loop. Open and closed Contour draw the same with SkPaint::kFill Style. With SkPaint::kStroke Style, open Contour draws Paint Stroke Cap at Contour start and end; closed Contour draws Paint Stroke Join at Contour start and end.

close has no effect if Path is empty or last Path Verb is kClose Verb.

Example

See Also


IsInverseFillType

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


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


ConvertConicToQuads

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


isRect

Returns true if Path is equivalent to Rect 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 Path bounds. Path bounds may include kMove Verb points that do not alter the area drawn by the returned rect.

Parameters

Return Value

true if Path contains Rect

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


isNestedFillRects

Returns true if Path is equivalent to nested Rect 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 Rect, and rect[1] to inner Rect; setting dirs[0] to Direction of outer Rect, and dirs[1] to Direction of inner Rect.

Parameters

Return Value

true if Path contains nested Rect 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


addRect

Add Rect to 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 kCW Direction; or followed by bottom-left, bottom-right, and top-right if dir is kCCW Direction.

Parameters

Example

See Also

SkCanvas::drawRect Direction


Add 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

Example

See Also

SkCanvas::drawRect Direction


Add Rect (left, top, right, bottom) to 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 kCW Direction; or followed by bottom-left, bottom-right, and top-right if dir is kCCW Direction.

Parameters

Example

See Also

SkCanvas::drawRect Direction


addOval

Add 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.

Parameters

Example

See Also

SkCanvas::drawOval Direction Oval


Add 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

Example

See Also

SkCanvas::drawOval Direction Oval


addCircle

Add 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

Example

See Also

SkCanvas::drawCircle[2] Direction Circle


addArc

Append Arc to 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 <= -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

Example

See Also

Arc arcTo[2][3][4][5] SkCanvas::drawArc


addRoundRect

Append 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 (rx, ry). 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 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 Rect rect to Path.

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

Parameters

Example

See Also

addRRect[2] SkCanvas::drawRoundRect


Append 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 RoundRect.

Parameters

Example

See Also

addRRect[2] SkCanvas::drawRoundRect


addRRect

Add rrect to Path, 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, Path may be empty, or may contain: Rect, Oval, or Round Rect.

Parameters

Example

See Also

addRoundRect[2] SkCanvas::drawRRect


Add 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

Example

See Also

addRoundRect[2] SkCanvas::drawRRect


addPoly

Add Contour created from Line array, adding (count - 1) Line segments. Contour added starts at pts[0], then adds a line for every additional Point in pts array. If close is true,appends kClose Verb to Path, 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

Example

See Also

SkCanvas::drawPoints


Enum SkPath::AddPathMode

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[2][3] reverseAddPath

addPath

Append src to Path, offset by (dx, dy).

If mode is kAppend AddPathMode, src Verb Array, Point Array, and Conic Weights are added unaltered. If mode is kExtend AddPathMode, add Line before appending Verbs, Points, and Conic Weights.

Parameters

Example

See Also

AddPathMode offset[2] reverseAddPath


Append src to Path.

If mode is kAppend AddPathMode, src Verb Array, Point Array, and Conic Weights are added unaltered. If mode is kExtend AddPathMode, add Line before appending Verbs, Points, and Conic Weights.

Parameters

Example

See Also

AddPathMode reverseAddPath


Append src to Path, transformed by matrix. Transformed curves may have different Verbs, Points, and Conic Weights.

If mode is kAppend AddPathMode, src Verb Array, Point Array, and Conic Weights are added unaltered. If mode is kExtend AddPathMode, add Line before appending Verbs, Points, and Conic Weights.

Parameters

Example

See Also

AddPathMode transform[2] offset[2] reverseAddPath


reverseAddPath

Append src to Path, from back to front. Reversed src always appends a new Contour to Path.

Parameters

Example

See Also

AddPathMode transform[2] offset[2] addPath[2][3]


offset

Offset Point Array by (dx, dy). Offset Path replaces dst. If dst is nullptr, Path is replaced by offset data.

Parameters

Example

See Also

addPath[2][3] transform[2]


Transform

Offset Point Array by (dx, dy). Path is replaced by offset data.

Parameters

Example

See Also

addPath[2][3] transform[2] SkCanvas::translate()


transform

Transform Verb Array, Point Array, and weight by matrix. transform may change Verbs and increase their number. Transformed Path replaces dst; if dst is nullptr, original data is replaced.

Parameters

Example

See Also

addPath[2][3] offset[2] SkCanvas::concat() SkMatrix


Transform Verb Array, Point Array, and weight by matrix. transform may change Verbs and increase their number. Path is replaced by transformed data.

Parameters

Example

See Also

addPath[2][3] offset[2] SkCanvas::concat() SkMatrix


Last Point

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.

getLastPt

Returns Last Point on Path in lastPt. Returns false if Point Array is empty, storing (0, 0) if lastPt is not nullptr.

Parameters

Return Value

true if Point Array contains one or more Points

Example

Example Output

last point: 35.2786, 52.9772

See Also

setLastPt[2]


setLastPt

Set Last Point to (x, y). If Point Array is empty, append kMove Verb to Verb Array and append (x, y) to Point Array.

Parameters

Example

See Also

getLastPt


Set the last point on the path. If Point Array is empty, append kMove Verb to Verb Array and append p to Point Array.

Parameters

Example

See Also

getLastPt


Enum SkPath::SegmentMask

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

getSegmentMasks

Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more Verbs of that type. Returns zero if Path 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


contains

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


dump

Writes text representation of Path to stream. If stream is nullptr, writes to standard output. Set forceClose to true to get edges used to fill Path. Set dumpAsHex true to generate exact binary representations of floating point numbers used in Point 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()[2] SkRRect::dump()[2] SkPathMeasure::dump()


Writes text representation of Path 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 Path 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()[2] SkRRect::dump()[2] SkPathMeasure::dump() writeToMemory


dumpHex

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[2] SkRect::dumpHex SkRRect::dumpHex writeToMemory


writeToMemory

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

Writes Fill Type, Verb Array, Point Array, Conic Weight, and additionally writes computed information like Convexity and bounds.

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

Parameters

Return Value

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

Example

Example Output

path is equal to copy

See Also

serialize readFromMemory dump[2] dumpHex


serialize

Write Path to buffer, returning the buffer written to, wrapped in Data.

serialize writes Fill Type, Verb Array, Point Array, Conic Weight, and additionally writes computed information like Convexity and bounds.

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

Return Value

Path data wrapped in Data buffer

Example

Example Output

path is equal to copy

See Also

writeToMemory readFromMemory dump[2] dumpHex


readFromMemory

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

Reads Fill Type, Verb Array, Point Array, Conic Weight, and additionally reads computed information like Convexity and bounds.

Used only in concert with writeToMemory; the format used for Path 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

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.

getGenerationID

Returns a non-zero, globally unique value. A different value is returned if Verb Array, Point Array, or Conic Weight changes.

Setting Fill Type does not change Generation ID.

Each time the path is modified, a different Generation ID will be returned.

Fill Type does affect Generation ID 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)


isValid

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

Return Value

true if Path data is consistent


pathRefIsValid

Deprecated.

soon


Class SkPath::Iter

Constructor

SkPath can be constructed or initialized by these functions, including C++ class constructors.

Member_Function

SkPath member functions read and modify the structure properties.

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

Iter

Initializes Iter with an empty Path. next on Iter returns kDone Verb. Call setPath to initialize Iter at a later time.

Return Value

Iter of empty Path

Example

Example Output

iter is done
iter is done

See Also

setPath


Iter

Sets Iter to return elements of Verb Array, Point Array, and Conic Weight in path. If forceClose is true, Iter will add kLine Verb and kClose Verb after each open Contour. path is not altered.

Parameters

Return Value

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


setPath

Sets Iter to return elements of Verb Array, Point Array, and Conic Weight in path. If forceClose is true, 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)


next

Returns next Verb in Verb Array, and advances Iter. When Verb Array is exhausted, returns kDone Verb.

Zero to four Points are stored in pts, depending on the returned 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 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


conicWeight

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 Points 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


isCloseLine

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


isClosedContour

Returns true if subsequent calls to next return kClose Verb before returning kMove Verb. if true, Contour Iter is processing may end with kClose Verb, or 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)


Class SkPath::RawIter

Constructor

SkPath can be constructed or initialized by these functions, including C++ class constructors.

Member_Function

SkPath member functions read and modify the structure properties.

Iterates through Verb Array, and associated Point Array and Conic Weight. Verb Array, Point Array, and Conic Weight are returned unaltered.

RawIter

Initializes RawIter with an empty Path. next on RawIter returns kDone Verb. Call setPath to initialize SkPath::Iter at a later time.

Return Value

RawIter of empty Path


RawIter

Sets RawIter to return elements of Verb Array, Point Array, and Conic Weight in path.

Parameters

Return Value

RawIter of path


setPath

Sets SkPath::Iter to return elements of Verb Array, Point Array, and Conic Weight in path.

Parameters


next

Returns next Verb in Verb Array, and advances RawIter. When Verb Array is exhausted, returns kDone Verb. Zero to four Points are stored in pts, depending on the returned Verb.

Parameters

Return Value

next 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


peek

Returns next Verb, but does not advance RawIter.

Return Value

next 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

StdOut is not really volatile, it just produces the wrong result. A simple fix changes the output of hairlines and needs to be investigated to see if the change is correct or not. see change 21340 (abandoned for now)

See Also

next


conicWeight

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 Points 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