Skia
2D Graphics Library
SkPath Class Reference

SkPath contain geometry. More...

#include <SkPath.h>

Classes

class  Iter
 Iterates through verb array, and associated SkPoint array and conic weight. More...
 
class  RawIter
 Iterates through verb array, and associated SkPoint array and conic weight. More...
 

Public Types

enum  ArcSize { kSmall_ArcSize, kLarge_ArcSize }
 
enum  AddPathMode { kAppend_AddPathMode, kExtend_AddPathMode }
 
enum  SegmentMask { kLine_SegmentMask = kLine_SkPathSegmentMask, kQuad_SegmentMask = kQuad_SkPathSegmentMask, kConic_SegmentMask = kConic_SkPathSegmentMask, kCubic_SegmentMask = kCubic_SkPathSegmentMask }
 
enum  Verb {
  kMove_Verb = static_cast<int>(SkPathVerb::kMove), kLine_Verb = static_cast<int>(SkPathVerb::kLine), kQuad_Verb = static_cast<int>(SkPathVerb::kQuad), kConic_Verb = static_cast<int>(SkPathVerb::kConic),
  kCubic_Verb = static_cast<int>(SkPathVerb::kCubic), kClose_Verb = static_cast<int>(SkPathVerb::kClose), kDone_Verb = static_cast<int>(SkPathVerb::kDone)
}
 

Public Member Functions

 SkPath ()
 Constructs an empty SkPath. More...
 
 SkPath (const SkPath &path)
 Constructs a copy of an existing path. More...
 
 ~SkPath ()
 Releases ownership of any shared data and deletes data if SkPath is sole owner. More...
 
SkPathoperator= (const SkPath &path)
 Constructs a copy of an existing path. More...
 
bool isInterpolatable (const SkPath &compare) const
 Returns true if SkPath contain equal verbs and equal weights. More...
 
bool interpolate (const SkPath &ending, SkScalar weight, SkPath *out) const
 Interpolates between SkPath with SkPoint array of equal size. More...
 
SkPathFillType getFillType () const
 Returns SkPathFillType, the rule used to fill SkPath. More...
 
void setFillType (SkPathFillType ft)
 Sets FillType, the rule used to fill SkPath. More...
 
bool isInverseFillType () const
 Returns if FillType describes area outside SkPath geometry. More...
 
void toggleInverseFillType ()
 Replaces FillType with its inverse. More...
 
SkPathConvexityType getConvexityType () const
 Returns the comvexity type, computing if needed. More...
 
SkPathConvexityType getConvexityTypeOrUnknown () const
 If the path's convexity is already known, return it, else return kUnknown. More...
 
void setConvexityType (SkPathConvexityType convexity)
 Stores a convexity type for this path. More...
 
bool isConvex () const
 Returns true if the path is convex. More...
 
bool isOval (SkRect *bounds) const
 Returns true if this path is recognized as an oval or circle. More...
 
bool isRRect (SkRRect *rrect) const
 Returns true if path is representable as SkRRect. More...
 
SkPathreset ()
 Sets SkPath to its initial state. More...
 
SkPathrewind ()
 Sets SkPath to its initial state, preserving internal storage. More...
 
bool isEmpty () const
 Returns if SkPath is empty. More...
 
bool isLastContourClosed () const
 Returns if contour is closed. More...
 
bool isFinite () const
 Returns true for finite SkPoint array values between negative SK_ScalarMax and positive SK_ScalarMax. More...
 
bool isVolatile () const
 Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn. More...
 
void setIsVolatile (bool isVolatile)
 Specifies whether SkPath is volatile; whether it will be altered or discarded by the caller after it is drawn. More...
 
bool isLine (SkPoint line[2]) const
 Returns true if SkPath contains only one line; SkPath::Verb array has two entries: kMove_Verb, kLine_Verb. More...
 
int countPoints () const
 Returns the number of points in SkPath. More...
 
SkPoint getPoint (int index) const
 Returns SkPoint at index in SkPoint array. More...
 
int getPoints (SkPoint points[], int max) const
 Returns number of points in SkPath. More...
 
int countVerbs () const
 Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb, kCubic_Verb, and kClose_Verb; added to SkPath. More...
 
int getVerbs (uint8_t verbs[], int max) const
 Returns the number of verbs in the path. More...
 
size_t approximateBytesUsed () const
 Returns the approximate byte size of the SkPath in memory. More...
 
void swap (SkPath &other)
 Exchanges the verb array, SkPoint array, weights, and SkPath::FillType with other. More...
 
const SkRectgetBounds () const
 Returns minimum and maximum axes values of SkPoint array. More...
 
void updateBoundsCache () const
 Updates internal bounds so that subsequent calls to getBounds() are instantaneous. More...
 
SkRect computeTightBounds () const
 Returns minimum and maximum axes values of the lines and curves in SkPath. More...
 
bool conservativelyContainsRect (const SkRect &rect) const
 Returns true if rect is contained by SkPath. More...
 
void incReserve (int extraPtCount)
 Grows SkPath verb array and SkPoint array to contain extraPtCount additional SkPoint. More...
 
void shrinkToFit ()
 Shrinks SkPath verb array and SkPoint array storage to discard unused capacity. More...
 
SkPathmoveTo (SkScalar x, SkScalar y)
 Adds beginning of contour at SkPoint (x, y). More...
 
SkPathmoveTo (const SkPoint &p)
 Adds beginning of contour at SkPoint p. More...
 
SkPathrMoveTo (SkScalar dx, SkScalar dy)
 Adds beginning of contour relative to last point. More...
 
SkPathlineTo (SkScalar x, SkScalar y)
 Adds line from last point to (x, y). More...
 
SkPathlineTo (const SkPoint &p)
 Adds line from last point to SkPoint p. More...
 
SkPathrLineTo (SkScalar dx, SkScalar dy)
 Adds line from last point to vector (dx, dy). More...
 
SkPathquadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 Adds quad from last point towards (x1, y1), to (x2, y2). More...
 
SkPathquadTo (const SkPoint &p1, const SkPoint &p2)
 Adds quad from last point towards SkPoint p1, to SkPoint p2. More...
 
SkPathrQuadTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2)
 Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2). More...
 
SkPathconicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w. More...
 
SkPathconicTo (const SkPoint &p1, const SkPoint &p2, SkScalar w)
 Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w. More...
 
SkPathrConicTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar w)
 Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w. More...
 
SkPathcubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3). More...
 
SkPathcubicTo (const SkPoint &p1, const SkPoint &p2, const SkPoint &p3)
 Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at SkPoint p3. More...
 
SkPathrCubicTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar dx3, SkScalar dy3)
 Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3). More...
 
SkPatharcTo (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
 Appends arc to SkPath. More...
 
SkPatharcTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius)
 Appends arc to SkPath, after appending line if needed. More...
 
SkPatharcTo (const SkPoint p1, const SkPoint p2, SkScalar radius)
 Appends arc to SkPath, after appending line if needed. More...
 
SkPatharcTo (SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkScalar x, SkScalar y)
 Appends arc to SkPath. More...
 
SkPatharcTo (const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, const SkPoint xy)
 Appends arc to SkPath. More...
 
SkPathrArcTo (SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkScalar dx, SkScalar dy)
 Appends arc to SkPath, relative to last SkPath SkPoint. More...
 
SkPathclose ()
 Appends kClose_Verb to SkPath. More...
 
bool isRect (SkRect *rect, bool *isClosed=nullptr, SkPathDirection *direction=nullptr) const
 Returns true if SkPath is equivalent to SkRect when filled. More...
 
SkPathaddRect (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW)
 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. More...
 
SkPathaddRect (const SkRect &rect, SkPathDirection dir, unsigned start)
 Adds SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb. More...
 
SkPathaddRect (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, SkPathDirection dir=SkPathDirection::kCW)
 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. More...
 
SkPathaddOval (const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
 Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. More...
 
SkPathaddOval (const SkRect &oval, SkPathDirection dir, unsigned start)
 Adds oval to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb. More...
 
SkPathaddCircle (SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
 Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb. More...
 
SkPathaddArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle)
 Appends arc to SkPath, as the start of new contour. More...
 
SkPathaddRoundRect (const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW)
 Appends SkRRect to SkPath, creating a new closed contour. More...
 
SkPathaddRoundRect (const SkRect &rect, const SkScalar radii[], SkPathDirection dir=SkPathDirection::kCW)
 Appends SkRRect to SkPath, creating a new closed contour. More...
 
SkPathaddRRect (const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
 Adds rrect to SkPath, creating a new closed contour. More...
 
SkPathaddRRect (const SkRRect &rrect, SkPathDirection dir, unsigned start)
 Adds rrect to SkPath, creating a new closed contour. More...
 
SkPathaddPoly (const SkPoint pts[], int count, bool close)
 Adds contour created from line array, adding (count - 1) line segments. More...
 
SkPathaddPoly (const std::initializer_list< SkPoint > &list, bool close)
 Adds contour created from list. More...
 
SkPathaddPath (const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
 Appends src to SkPath, offset by (dx, dy). More...
 
SkPathaddPath (const SkPath &src, AddPathMode mode=kAppend_AddPathMode)
 Appends src to SkPath. More...
 
SkPathaddPath (const SkPath &src, const SkMatrix &matrix, AddPathMode mode=kAppend_AddPathMode)
 Appends src to SkPath, transformed by matrix. More...
 
SkPathreverseAddPath (const SkPath &src)
 Appends src to SkPath, from back to front. More...
 
void offset (SkScalar dx, SkScalar dy, SkPath *dst) const
 Offsets SkPoint array by (dx, dy). More...
 
void offset (SkScalar dx, SkScalar dy)
 Offsets SkPoint array by (dx, dy). More...
 
void transform (const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
 Transforms verb array, SkPoint array, and weight by matrix. More...
 
void transform (const SkMatrix &matrix, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes)
 Transforms verb array, SkPoint array, and weight by matrix. More...
 
bool getLastPt (SkPoint *lastPt) const
 Returns last point on SkPath in lastPt. More...
 
void setLastPt (SkScalar x, SkScalar y)
 Sets last point to (x, y). More...
 
void setLastPt (const SkPoint &p)
 Sets the last point on the path. More...
 
uint32_t getSegmentMasks () const
 Returns a mask, where each set bit corresponds to a SegmentMask constant if SkPath contains one or more verbs of that type. More...
 
bool contains (SkScalar x, SkScalar y) const
 Returns true if the point (x, y) is contained by SkPath, taking into account FillType. More...
 
void dump (SkWStream *stream, bool forceClose, bool dumpAsHex) const
 Writes text representation of SkPath to stream. More...
 
void dump () const
 Writes text representation of SkPath to standard output. More...
 
void dumpHex () const
 Writes text representation of SkPath to standard output. More...
 
size_t writeToMemory (void *buffer) const
 Writes SkPath to buffer, returning the number of bytes written. More...
 
sk_sp< SkDataserialize () const
 Writes SkPath to buffer, returning the buffer written to, wrapped in SkData. More...
 
size_t readFromMemory (const void *buffer, size_t length)
 Initializes SkPath from buffer of size length. More...
 
uint32_t getGenerationID () const
 (See Skia bug 1762.) Returns a non-zero, globally unique value. More...
 
bool isValid () const
 Returns if SkPath data is consistent. More...
 

Static Public Member Functions

static bool IsLineDegenerate (const SkPoint &p1, const SkPoint &p2, bool exact)
 Tests if line between SkPoint pair is degenerate. More...
 
static bool IsQuadDegenerate (const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, bool exact)
 Tests if quad is degenerate. More...
 
static bool IsCubicDegenerate (const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, const SkPoint &p4, bool exact)
 Tests if cubic is degenerate. More...
 
static int ConvertConicToQuads (const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, SkScalar w, SkPoint pts[], int pow2)
 Approximates conic with quad array. More...
 

Friends

class Iter
 
class SkPathPriv
 
class SkPathStroker
 
class SkAutoPathBoundsUpdate
 
class SkAutoDisableOvalCheck
 
class SkAutoDisableDirectionCheck
 
class SkPathEdgeIter
 
class SkPathWriter
 
class SkOpBuilder
 
class SkBench_AddPathTest
 
class PathTest_Private
 
class ForceIsRRect_Private
 
class FuzzPath
 
SK_API bool operator== (const SkPath &a, const SkPath &b)
 Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights are equivalent. More...
 
bool operator!= (const SkPath &a, const SkPath &b)
 Compares a and b; returns true if SkPath::FillType, verb array, SkPoint array, and weights are not equivalent. More...
 

Detailed Description

SkPath contain geometry.

SkPath may be empty, or contain one or more verbs that outline a figure. SkPath 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. SkPath may contain any number of contours, each beginning with a move verb.

SkPath contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers. SkPath contours may be open or closed.

When used to draw a filled area, SkPath describes whether the fill is inside or outside the geometry. SkPath also describes the winding rule used to fill overlapping contours.

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

Member Enumeration Documentation

◆ AddPathMode

Enumerator
kAppend_AddPathMode 

appended to destination unaltered

kExtend_AddPathMode 

add line if prior contour is not closed

◆ ArcSize

Enumerator
kSmall_ArcSize 

smaller of arc pair

kLarge_ArcSize 

larger of arc pair

◆ SegmentMask

Enumerator
kLine_SegmentMask 
kQuad_SegmentMask 
kConic_SegmentMask 
kCubic_SegmentMask 

◆ Verb

Enumerator
kMove_Verb 
kLine_Verb 
kQuad_Verb 
kConic_Verb 
kCubic_Verb 
kClose_Verb 
kDone_Verb 

Constructor & Destructor Documentation

◆ SkPath() [1/2]

SkPath::SkPath ( )

Constructs an empty SkPath.

By default, SkPath has no verbs, no SkPoint, and no weights. FillType is set to kWinding.

Returns
empty SkPath

example: https://fiddle.skia.org/c/@Path_empty_constructor

◆ SkPath() [2/2]

SkPath::SkPath ( const SkPath path)

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
pathSkPath to copy by value
Returns
copy of SkPath

example: https://fiddle.skia.org/c/@Path_copy_const_SkPath

◆ ~SkPath()

SkPath::~SkPath ( )

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

example: https://fiddle.skia.org/c/@Path_destructor

Member Function Documentation

◆ addArc()

SkPath& SkPath::addArc ( const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle 
)

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
ovalbounds of ellipse containing arc
startAnglestarting angle of arc in degrees
sweepAnglesweep, in degrees. Positive is clockwise; treated modulo 360
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addArc

◆ addCircle()

SkPath& SkPath::addCircle ( SkScalar  x,
SkScalar  y,
SkScalar  radius,
SkPathDirection  dir = SkPathDirection::kCW 
)

Adds circle centered at (x, y) of size radius to SkPath, 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
xcenter of circle
ycenter of circle
radiusdistance from center to edge
dirSkPath::Direction to wind circle
Returns
reference to SkPath

◆ addOval() [1/2]

SkPath& SkPath::addOval ( const SkRect oval,
SkPathDirection  dir = SkPathDirection::kCW 
)

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
ovalbounds of ellipse added
dirSkPath::Direction to wind ellipse
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addOval

◆ addOval() [2/2]

SkPath& SkPath::addOval ( const SkRect oval,
SkPathDirection  dir,
unsigned  start 
)

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

Parameters
ovalbounds of ellipse added
dirSkPath::Direction to wind ellipse
startindex of initial point of ellipse
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addOval_2

◆ addPath() [1/3]

SkPath& SkPath::addPath ( const SkPath src,
SkScalar  dx,
SkScalar  dy,
AddPathMode  mode = kAppend_AddPathMode 
)

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
srcSkPath verbs, SkPoint, and conic weights to add
dxoffset added to src SkPoint array x-axis coordinates
dyoffset added to src SkPoint array y-axis coordinates
modekAppend_AddPathMode or kExtend_AddPathMode
Returns
reference to SkPath

◆ addPath() [2/3]

SkPath& SkPath::addPath ( const SkPath src,
AddPathMode  mode = kAppend_AddPathMode 
)
inline

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
srcSkPath verbs, SkPoint, and conic weights to add
modekAppend_AddPathMode or kExtend_AddPathMode
Returns
reference to SkPath

◆ addPath() [3/3]

SkPath& SkPath::addPath ( const SkPath src,
const SkMatrix matrix,
AddPathMode  mode = kAppend_AddPathMode 
)

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
srcSkPath verbs, SkPoint, and conic weights to add
matrixtransform applied to src
modekAppend_AddPathMode or kExtend_AddPathMode
Returns
reference to SkPath

◆ addPoly() [1/2]

SkPath& SkPath::addPoly ( const SkPoint  pts[],
int  count,
bool  close 
)

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
ptsarray of line sharing end and start SkPoint
countlength of SkPoint array
closetrue to add line connecting contour end and start
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addPoly

◆ addPoly() [2/2]

SkPath& SkPath::addPoly ( const std::initializer_list< SkPoint > &  list,
bool  close 
)
inline

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
listarray of SkPoint
closetrue to add line connecting contour end and start
Returns
reference to SkPath

◆ addRect() [1/3]

SkPath& SkPath::addRect ( const SkRect rect,
SkPathDirection  dir = SkPathDirection::kCW 
)

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
rectSkRect to add as a closed contour
dirSkPath::Direction to wind added contour
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addRect

◆ addRect() [2/3]

SkPath& SkPath::addRect ( const SkRect rect,
SkPathDirection  dir,
unsigned  start 
)

Adds SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb.

If dir is kCW_Direction, SkRect corners are added clockwise; if dir is kCCW_Direction, SkRect corners are added counterclockwise. start determines the first corner added.

Parameters
rectSkRect to add as a closed contour
dirSkPath::Direction to wind added contour
startinitial corner of SkRect to add
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addRect_2

◆ addRect() [3/3]

SkPath& SkPath::addRect ( SkScalar  left,
SkScalar  top,
SkScalar  right,
SkScalar  bottom,
SkPathDirection  dir = SkPathDirection::kCW 
)

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
leftsmaller x-axis value of SkRect
topsmaller y-axis value of SkRect
rightlarger x-axis value of SkRect
bottomlarger y-axis value of SkRect
dirSkPath::Direction to wind added contour
Returns
reference to SkPath

◆ addRoundRect() [1/2]

SkPath& SkPath::addRoundRect ( const SkRect rect,
SkScalar  rx,
SkScalar  ry,
SkPathDirection  dir = SkPathDirection::kCW 
)

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
rectbounds of SkRRect
rxx-axis radius of rounded corners on the SkRRect
ryy-axis radius of rounded corners on the SkRRect
dirSkPath::Direction to wind SkRRect
Returns
reference to SkPath

◆ addRoundRect() [2/2]

SkPath& SkPath::addRoundRect ( const SkRect rect,
const SkScalar  radii[],
SkPathDirection  dir = SkPathDirection::kCW 
)

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 from the array.

Parameters
rectbounds of SkRRect
radiiarray of 8 SkScalar values, a radius pair for each corner
dirSkPath::Direction to wind SkRRect
Returns
reference to SkPath

◆ addRRect() [1/2]

SkPath& SkPath::addRRect ( const SkRRect rrect,
SkPathDirection  dir = SkPathDirection::kCW 
)

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
rrectbounds and radii of rounded rectangle
dirSkPath::Direction to wind SkRRect
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addRRect

◆ addRRect() [2/2]

SkPath& SkPath::addRRect ( const SkRRect rrect,
SkPathDirection  dir,
unsigned  start 
)

Adds rrect to SkPath, 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.

Parameters
rrectbounds and radii of rounded rectangle
dirSkPath::Direction to wind SkRRect
startindex of initial point of SkRRect
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_addRRect_2

◆ approximateBytesUsed()

size_t SkPath::approximateBytesUsed ( ) const

Returns the approximate byte size of the SkPath in memory.

Returns
approximate size

◆ arcTo() [1/5]

SkPath& SkPath::arcTo ( const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle,
bool  forceMoveTo 
)

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
ovalbounds of ellipse containing arc
startAnglestarting angle of arc in degrees
sweepAnglesweep, in degrees. Positive is clockwise; treated modulo 360
forceMoveTotrue to start a new contour with arc
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_arcTo

◆ arcTo() [2/5]

SkPath& SkPath::arcTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  radius 
)

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
x1x-axis value common to pair of tangents
y1y-axis value common to pair of tangents
x2x-axis value end of second tangent
y2y-axis value end of second tangent
radiusdistance from arc to circle center
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_arcTo_2_a example: https://fiddle.skia.org/c/@Path_arcTo_2_b example: https://fiddle.skia.org/c/@Path_arcTo_2_c

◆ arcTo() [3/5]

SkPath& SkPath::arcTo ( const SkPoint  p1,
const SkPoint  p2,
SkScalar  radius 
)
inline

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
p1SkPoint common to pair of tangents
p2end of second tangent
radiusdistance from arc to circle center
Returns
reference to SkPath

◆ arcTo() [4/5]

SkPath& SkPath::arcTo ( SkScalar  rx,
SkScalar  ry,
SkScalar  xAxisRotate,
ArcSize  largeArc,
SkPathDirection  sweep,
SkScalar  x,
SkScalar  y 
)

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
rxradius on x-axis before x-axis rotation
ryradius on y-axis before x-axis rotation
xAxisRotatex-axis rotation in degrees; positive values are clockwise
largeArcchooses smaller or larger arc
sweepchooses clockwise or counterclockwise arc
xend of arc
yend of arc
Returns
reference to SkPath

◆ arcTo() [5/5]

SkPath& SkPath::arcTo ( const SkPoint  r,
SkScalar  xAxisRotate,
ArcSize  largeArc,
SkPathDirection  sweep,
const SkPoint  xy 
)
inline

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
rradii on axes before x-axis rotation
xAxisRotatex-axis rotation in degrees; positive values are clockwise
largeArcchooses smaller or larger arc
sweepchooses clockwise or counterclockwise arc
xyend of arc
Returns
reference to SkPath

◆ close()

SkPath& SkPath::close ( )

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.

Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_close

◆ computeTightBounds()

SkRect SkPath::computeTightBounds ( ) const

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.

Returns
tight bounds of curves in SkPath

example: https://fiddle.skia.org/c/@Path_computeTightBounds

◆ conicTo() [1/2]

SkPath& SkPath::conicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  w 
)

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
x1control SkPoint of conic on x-axis
y1control SkPoint of conic on y-axis
x2end SkPoint of conic on x-axis
y2end SkPoint of conic on y-axis
wweight of added conic
Returns
reference to SkPath

◆ conicTo() [2/2]

SkPath& SkPath::conicTo ( const SkPoint p1,
const SkPoint p2,
SkScalar  w 
)
inline

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
p1control SkPoint of added conic
p2end SkPoint of added conic
wweight of added conic
Returns
reference to SkPath

◆ conservativelyContainsRect()

bool SkPath::conservativelyContainsRect ( const SkRect rect) const

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
rectSkRect, line, or SkPoint checked for containment
Returns
true if rect is contained

example: https://fiddle.skia.org/c/@Path_conservativelyContainsRect

◆ contains()

bool SkPath::contains ( SkScalar  x,
SkScalar  y 
) const

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

Parameters
xx-axis value of containment test
yy-axis value of containment test
Returns
true if SkPoint is in SkPath

example: https://fiddle.skia.org/c/@Path_contains

◆ ConvertConicToQuads()

static int SkPath::ConvertConicToQuads ( const SkPoint p0,
const SkPoint p1,
const SkPoint p2,
SkScalar  w,
SkPoint  pts[],
int  pow2 
)
static

Approximates conic with quad array.

Conic is constructed from start SkPoint p0, control SkPoint p1, end SkPoint 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 SkPoint of previous quad and first SkPoint 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
p0conic start SkPoint
p1conic control SkPoint
p2conic end SkPoint
wconic weight
ptsstorage for quad array
pow2quad count, as power of two, normally 0 to 5 (1 to 32 quad curves)
Returns
number of quad curves written to pts

◆ countPoints()

int SkPath::countPoints ( ) const

Returns the number of points in SkPath.

SkPoint count is initially zero.

Returns
SkPath SkPoint array length

example: https://fiddle.skia.org/c/@Path_countPoints

◆ countVerbs()

int SkPath::countVerbs ( ) const

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

Returns
length of verb array

example: https://fiddle.skia.org/c/@Path_countVerbs

◆ cubicTo() [1/2]

SkPath& SkPath::cubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)

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
x1first control SkPoint of cubic on x-axis
y1first control SkPoint of cubic on y-axis
x2second control SkPoint of cubic on x-axis
y2second control SkPoint of cubic on y-axis
x3end SkPoint of cubic on x-axis
y3end SkPoint of cubic on y-axis
Returns
reference to SkPath

◆ cubicTo() [2/2]

SkPath& SkPath::cubicTo ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3 
)
inline

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
p1first control SkPoint of cubic
p2second control SkPoint of cubic
p3end SkPoint of cubic
Returns
reference to SkPath

◆ dump() [1/2]

void SkPath::dump ( SkWStream stream,
bool  forceClose,
bool  dumpAsHex 
) const

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
streamwritable SkWStream receiving SkPath text representation; may be nullptr
forceClosetrue if missing kClose_Verb is output
dumpAsHextrue if SkScalar values are written as hexadecimal

example: https://fiddle.skia.org/c/@Path_dump

◆ dump() [2/2]

void SkPath::dump ( ) const

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: https://fiddle.skia.org/c/@Path_dump_2

◆ dumpHex()

void SkPath::dumpHex ( ) const

Writes text representation of SkPath 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 SkPath.

Use instead of dump() when submitting

example: https://fiddle.skia.org/c/@Path_dumpHex

◆ getBounds()

const SkRect& SkPath::getBounds ( ) const
inline

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.

Returns
bounds of all SkPoint in SkPoint array

◆ getConvexityType()

SkPathConvexityType SkPath::getConvexityType ( ) const
inline

Returns the comvexity type, computing if needed.

Never returns kUnknown.

Returns
path's convexity type (convex or concave)

◆ getConvexityTypeOrUnknown()

SkPathConvexityType SkPath::getConvexityTypeOrUnknown ( ) const
inline

If the path's convexity is already known, return it, else return kUnknown.

If you always want to know the convexity, even if that means having to compute it, call getConvexitytype().

Returns
known convexity, or kUnknown

◆ getFillType()

SkPathFillType SkPath::getFillType ( ) const
inline

Returns SkPathFillType, the rule used to fill SkPath.

Returns
current SkPathFillType setting

◆ getGenerationID()

uint32_t SkPath::getGenerationID ( ) const

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

Returns
non-zero, globally unique value

example: https://fiddle.skia.org/c/@Path_getGenerationID

◆ getLastPt()

bool SkPath::getLastPt ( SkPoint lastPt) const

Returns last point on SkPath in lastPt.

Returns false if SkPoint array is empty, storing (0, 0) if lastPt is not nullptr.

Parameters
lastPtstorage for final SkPoint in SkPoint array; may be nullptr
Returns
true if SkPoint array contains one or more SkPoint

example: https://fiddle.skia.org/c/@Path_getLastPt

◆ getPoint()

SkPoint SkPath::getPoint ( int  index) const

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
indexSkPoint array element selector
Returns
SkPoint array value or (0, 0)

example: https://fiddle.skia.org/c/@Path_getPoint

◆ getPoints()

int SkPath::getPoints ( SkPoint  points[],
int  max 
) const

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
pointsstorage for SkPath SkPoint array. May be nullptr
maxmaximum to copy; must be greater than or equal to zero
Returns
SkPath SkPoint array length

example: https://fiddle.skia.org/c/@Path_getPoints

◆ getSegmentMasks()

uint32_t SkPath::getSegmentMasks ( ) const
inline

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.

Returns
SegmentMask bits or zero

◆ getVerbs()

int SkPath::getVerbs ( uint8_t  verbs[],
int  max 
) const

Returns the number of verbs in the path.

Up to max verbs are copied. The verbs are copied as one byte per verb.

Parameters
verbsstorage for verbs, may be nullptr
maxmaximum number to copy into verbs
Returns
the actual number of verbs in the path

example: https://fiddle.skia.org/c/@Path_getVerbs

◆ incReserve()

void SkPath::incReserve ( int  extraPtCount)

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
extraPtCountnumber of additional SkPoint to allocate

example: https://fiddle.skia.org/c/@Path_incReserve

◆ interpolate()

bool SkPath::interpolate ( const SkPath ending,
SkScalar  weight,
SkPath out 
) const

Interpolates between SkPath with SkPoint array of equal size.

Copy verb array and weights to out, and set out SkPoint array to a weighted average of this SkPoint array and ending SkPoint array, using the formula: (Path Point * weight) + ending Point * (1 - weight).

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

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

Parameters
endingSkPoint array averaged with this SkPoint array
weightcontribution of this SkPoint array, and one minus contribution of ending SkPoint array
outSkPath replaced by interpolated averages
Returns
true if SkPath contain same number of SkPoint

example: https://fiddle.skia.org/c/@Path_interpolate

◆ isConvex()

bool SkPath::isConvex ( ) const
inline

Returns true if the path is convex.

If necessary, it will first compute the convexity.

◆ IsCubicDegenerate()

static bool SkPath::IsCubicDegenerate ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3,
const SkPoint p4,
bool  exact 
)
static

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
p1cubic start point
p2cubic control point 1
p3cubic control point 2
p4cubic end point
exactif true, returns true only if p1, p2, p3, and p4 are equal; if false, returns true if p1, p2, p3, and p4 are equal or nearly equal
Returns
true if cubic is degenerate; its length is effectively zero

◆ isEmpty()

bool SkPath::isEmpty ( ) const
inline

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.

Returns
true if the path contains no SkPath::Verb array

◆ isFinite()

bool SkPath::isFinite ( ) const
inline

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.

Returns
true if all SkPoint values are finite

◆ isInterpolatable()

bool SkPath::isInterpolatable ( const SkPath compare) const

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
compareSkPath to compare
Returns
true if SkPath verb array and weights are equivalent

example: https://fiddle.skia.org/c/@Path_isInterpolatable

◆ isInverseFillType()

bool SkPath::isInverseFillType ( ) const
inline

Returns if FillType describes area outside SkPath geometry.

The inverse fill area extends indefinitely.

Returns
true if FillType is kInverseWinding or kInverseEvenOdd

◆ isLastContourClosed()

bool SkPath::isLastContourClosed ( ) const

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.

Returns
true if the last contour ends with a kClose_Verb

example: https://fiddle.skia.org/c/@Path_isLastContourClosed

◆ isLine()

bool SkPath::isLine ( SkPoint  line[2]) const

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
linestorage for line. May be nullptr
Returns
true if SkPath contains exactly one line

example: https://fiddle.skia.org/c/@Path_isLine

◆ IsLineDegenerate()

static bool SkPath::IsLineDegenerate ( const SkPoint p1,
const SkPoint p2,
bool  exact 
)
static

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
p1line start point
p2line end point
exactif false, allow nearly equals
Returns
true if line is degenerate; its length is effectively zero

example: https://fiddle.skia.org/c/@Path_IsLineDegenerate

◆ isOval()

bool SkPath::isOval ( SkRect bounds) const

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
boundsstorage for bounding SkRect of oval; may be nullptr
Returns
true if SkPath is recognized as an oval or circle

example: https://fiddle.skia.org/c/@Path_isOval

◆ IsQuadDegenerate()

static bool SkPath::IsQuadDegenerate ( const SkPoint p1,
const SkPoint p2,
const SkPoint p3,
bool  exact 
)
static

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
p1quad start point
p2quad control point
p3quad end point
exactif true, returns true only if p1, p2, and p3 are equal; if false, returns true if p1, p2, and p3 are equal or nearly equal
Returns
true if quad is degenerate; its length is effectively zero

◆ isRect()

bool SkPath::isRect ( SkRect rect,
bool *  isClosed = nullptr,
SkPathDirection direction = nullptr 
) const

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
rectstorage for bounds of SkRect; may be nullptr
isClosedstorage set to true if SkPath is closed; may be nullptr
directionstorage set to SkRect direction; may be nullptr
Returns
true if SkPath contains SkRect

example: https://fiddle.skia.org/c/@Path_isRect

◆ isRRect()

bool SkPath::isRRect ( SkRRect rrect) const

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
rrectstorage for bounding SkRect of SkRRect; may be nullptr
Returns
true if SkPath contains only SkRRect

example: https://fiddle.skia.org/c/@Path_isRRect

◆ isValid()

bool SkPath::isValid ( ) const
inline

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.

Returns
true if SkPath data is consistent

◆ isVolatile()

bool SkPath::isVolatile ( ) const
inline

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.

Returns
true if caller will alter SkPath after drawing

◆ lineTo() [1/2]

SkPath& SkPath::lineTo ( SkScalar  x,
SkScalar  y 
)

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
xend of added line on x-axis
yend of added line on y-axis
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_lineTo

◆ lineTo() [2/2]

SkPath& SkPath::lineTo ( const SkPoint p)
inline

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
pend SkPoint of added line
Returns
reference to SkPath

◆ moveTo() [1/2]

SkPath& SkPath::moveTo ( SkScalar  x,
SkScalar  y 
)

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

Parameters
xx-axis value of contour start
yy-axis value of contour start
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_moveTo

◆ moveTo() [2/2]

SkPath& SkPath::moveTo ( const SkPoint p)
inline

Adds beginning of contour at SkPoint p.

Parameters
pcontour start
Returns
reference to SkPath

◆ offset() [1/2]

void SkPath::offset ( SkScalar  dx,
SkScalar  dy,
SkPath dst 
) const

Offsets SkPoint array by (dx, dy).

Offset SkPath replaces dst. If dst is nullptr, SkPath is replaced by offset data.

Parameters
dxoffset added to SkPoint array x-axis coordinates
dyoffset added to SkPoint array y-axis coordinates
dstoverwritten, translated copy of SkPath; may be nullptr

example: https://fiddle.skia.org/c/@Path_offset

◆ offset() [2/2]

void SkPath::offset ( SkScalar  dx,
SkScalar  dy 
)
inline

Offsets SkPoint array by (dx, dy).

SkPath is replaced by offset data.

Parameters
dxoffset added to SkPoint array x-axis coordinates
dyoffset added to SkPoint array y-axis coordinates

◆ operator=()

SkPath& SkPath::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
pathverb array, SkPoint array, weights, and SkPath::FillType to copy
Returns
SkPath copied by value

example: https://fiddle.skia.org/c/@Path_copy_operator

◆ quadTo() [1/2]

SkPath& SkPath::quadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)

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
x1control SkPoint of quad on x-axis
y1control SkPoint of quad on y-axis
x2end SkPoint of quad on x-axis
y2end SkPoint of quad on y-axis
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_quadTo

◆ quadTo() [2/2]

SkPath& SkPath::quadTo ( const SkPoint p1,
const SkPoint p2 
)
inline

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
p1control SkPoint of added quad
p2end SkPoint of added quad
Returns
reference to SkPath

◆ rArcTo()

SkPath& SkPath::rArcTo ( SkScalar  rx,
SkScalar  ry,
SkScalar  xAxisRotate,
ArcSize  largeArc,
SkPathDirection  sweep,
SkScalar  dx,
SkScalar  dy 
)

Appends arc to SkPath, relative to last SkPath SkPoint.

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

Arc sweep is always less than 360 degrees. arcTo() appends line to end SkPoint if either radii are zero, or if last SkPath SkPoint equals end SkPoint. arcTo() scales radii (rx, ry) to fit last SkPath SkPoint and end SkPoint 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
rxradius before x-axis rotation
ryradius before x-axis rotation
xAxisRotatex-axis rotation in degrees; positive values are clockwise
largeArcchooses smaller or larger arc
sweepchooses clockwise or counterclockwise arc
dxx-axis offset end of arc from last SkPath SkPoint
dyy-axis offset end of arc from last SkPath SkPoint
Returns
reference to SkPath

◆ rConicTo()

SkPath& SkPath::rConicTo ( SkScalar  dx1,
SkScalar  dy1,
SkScalar  dx2,
SkScalar  dy2,
SkScalar  w 
)

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
dx1offset from last point to conic control on x-axis
dy1offset from last point to conic control on y-axis
dx2offset from last point to conic end on x-axis
dy2offset from last point to conic end on y-axis
wweight of added conic
Returns
reference to SkPath

◆ rCubicTo()

SkPath& SkPath::rCubicTo ( SkScalar  dx1,
SkScalar  dy1,
SkScalar  dx2,
SkScalar  dy2,
SkScalar  dx3,
SkScalar  dy3 
)

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
dx1offset from last point to first cubic control on x-axis
dy1offset from last point to first cubic control on y-axis
dx2offset from last point to second cubic control on x-axis
dy2offset from last point to second cubic control on y-axis
dx3offset from last point to cubic end on x-axis
dy3offset from last point to cubic end on y-axis
Returns
reference to SkPath

◆ readFromMemory()

size_t SkPath::readFromMemory ( const void *  buffer,
size_t  length 
)

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
bufferstorage for SkPath
lengthbuffer size in bytes; must be multiple of 4
Returns
number of bytes read, or zero on failure

example: https://fiddle.skia.org/c/@Path_readFromMemory

◆ reset()

SkPath& SkPath::reset ( )

Sets SkPath to its initial state.

Removes verb array, SkPoint array, and weights, and sets FillType to kWinding. Internal storage associated with SkPath is released.

Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_reset

◆ reverseAddPath()

SkPath& SkPath::reverseAddPath ( const SkPath src)

Appends src to SkPath, from back to front.

Reversed src always appends a new contour to SkPath.

Parameters
srcSkPath verbs, SkPoint, and conic weights to add
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_reverseAddPath

◆ rewind()

SkPath& SkPath::rewind ( )

Sets SkPath to its initial state, preserving internal storage.

Removes verb array, SkPoint array, and weights, and sets FillType to kWinding. Internal storage associated with SkPath is retained.

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

Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_rewind

◆ rLineTo()

SkPath& SkPath::rLineTo ( SkScalar  dx,
SkScalar  dy 
)

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
dxoffset from last point to line end on x-axis
dyoffset from last point to line end on y-axis
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_rLineTo example: https://fiddle.skia.org/c/@Quad_a example: https://fiddle.skia.org/c/@Quad_b

◆ rMoveTo()

SkPath& SkPath::rMoveTo ( SkScalar  dx,
SkScalar  dy 
)

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
dxoffset from last point to contour start on x-axis
dyoffset from last point to contour start on y-axis
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Path_rMoveTo

◆ rQuadTo()

SkPath& SkPath::rQuadTo ( SkScalar  dx1,
SkScalar  dy1,
SkScalar  dx2,
SkScalar  dy2 
)

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
dx1offset from last point to quad control on x-axis
dy1offset from last point to quad control on y-axis
dx2offset from last point to quad end on x-axis
dy2offset from last point to quad end on y-axis
Returns
reference to SkPath

example: https://fiddle.skia.org/c/@Conic_Weight_a example: https://fiddle.skia.org/c/@Conic_Weight_b example: https://fiddle.skia.org/c/@Conic_Weight_c example: https://fiddle.skia.org/c/@Path_rQuadTo

◆ serialize()

sk_sp<SkData> SkPath::serialize ( ) const

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.

Returns
SkPath data wrapped in SkData buffer

example: https://fiddle.skia.org/c/@Path_serialize

◆ setConvexityType()

void SkPath::setConvexityType ( SkPathConvexityType  convexity)

Stores a convexity type for this path.

This is what will be returned if getConvexityTypeOrUnknown() is called. If you pass kUnknown, then if getContexityType() is called, the real convexity will be computed.

example: https://fiddle.skia.org/c/@Path_setConvexity

◆ setFillType()

void SkPath::setFillType ( SkPathFillType  ft)
inline

Sets FillType, the rule used to fill SkPath.

While there is no check that ft is legal, values outside of FillType are not supported.

◆ setIsVolatile()

void SkPath::setIsVolatile ( bool  isVolatile)
inline

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
isVolatiletrue if caller will alter SkPath after drawing

◆ setLastPt() [1/2]

void SkPath::setLastPt ( SkScalar  x,
SkScalar  y 
)

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
xset x-axis value of last point
yset y-axis value of last point

example: https://fiddle.skia.org/c/@Path_setLastPt

◆ setLastPt() [2/2]

void SkPath::setLastPt ( const SkPoint p)
inline

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
pset value of last point

◆ shrinkToFit()

void SkPath::shrinkToFit ( )

Shrinks SkPath verb array and SkPoint array storage to discard unused capacity.

May reduce the heap overhead for SkPath known to be fully constructed.

◆ swap()

void SkPath::swap ( SkPath other)

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
otherSkPath exchanged by value

example: https://fiddle.skia.org/c/@Path_swap

◆ toggleInverseFillType()

void SkPath::toggleInverseFillType ( )
inline

Replaces FillType with its inverse.

The inverse of FillType describes the area unmodified by the original FillType.

◆ transform() [1/2]

void SkPath::transform ( const SkMatrix matrix,
SkPath dst,
SkApplyPerspectiveClip  pc = SkApplyPerspectiveClip::kYes 
) const

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
matrixSkMatrix to apply to SkPath
dstoverwritten, transformed copy of SkPath; may be nullptr
pcwhether to apply perspective clipping

example: https://fiddle.skia.org/c/@Path_transform

◆ transform() [2/2]

void SkPath::transform ( const SkMatrix matrix,
SkApplyPerspectiveClip  pc = SkApplyPerspectiveClip::kYes 
)
inline

Transforms verb array, SkPoint array, and weight by matrix.

transform may change verbs and increase their number. SkPath is replaced by transformed data.

Parameters
matrixSkMatrix to apply to SkPath
pcwhether to apply perspective clipping

◆ updateBoundsCache()

void SkPath::updateBoundsCache ( ) const
inline

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.

◆ writeToMemory()

size_t SkPath::writeToMemory ( void *  buffer) const

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
bufferstorage for SkPath; may be nullptr
Returns
size of storage required for SkPath; always a multiple of 4

example: https://fiddle.skia.org/c/@Path_writeToMemory

Friends And Related Function Documentation

◆ ForceIsRRect_Private

friend class ForceIsRRect_Private
friend

◆ FuzzPath

friend class FuzzPath
friend

◆ Iter

friend class Iter
friend

◆ operator!=

bool operator!= ( const SkPath a,
const SkPath b 
)
friend

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

Parameters
aSkPath to compare
bSkPath to compare
Returns
true if SkPath pair are not equivalent

◆ operator==

SK_API bool operator== ( const SkPath a,
const SkPath b 
)
friend

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

Parameters
aSkPath to compare
bSkPath to compare
Returns
true if SkPath pair are equivalent

◆ PathTest_Private

friend class PathTest_Private
friend

◆ SkAutoDisableDirectionCheck

friend class SkAutoDisableDirectionCheck
friend

◆ SkAutoDisableOvalCheck

friend class SkAutoDisableOvalCheck
friend

◆ SkAutoPathBoundsUpdate

friend class SkAutoPathBoundsUpdate
friend

◆ SkBench_AddPathTest

friend class SkBench_AddPathTest
friend

◆ SkOpBuilder

friend class SkOpBuilder
friend

◆ SkPathEdgeIter

friend class SkPathEdgeIter
friend

◆ SkPathPriv

friend class SkPathPriv
friend

◆ SkPathStroker

friend class SkPathStroker
friend

◆ SkPathWriter

friend class SkPathWriter
friend

The documentation for this class was generated from the following file: