Skia
2D Graphics Library
|
SkPath contain geometry. More...
#include <SkPath.h>
Classes | |
class | Iter |
Iterates through verb array, and associated SkPoint array and conic weight. More... | |
class | RawIter |
Use Iter instead. 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 = kClose_Verb + 1 } |
using | sk_is_trivially_relocatable = std::true_type |
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... | |
SkPath & | operator= (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... | |
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... | |
SkPath & | reset () |
Sets SkPath to its initial state. More... | |
SkPath & | rewind () |
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... | |
SkPath & | 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 SkRect & | getBounds () 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... | |
SkPath & | moveTo (SkScalar x, SkScalar y) |
Adds beginning of contour at SkPoint (x, y). More... | |
SkPath & | moveTo (const SkPoint &p) |
Adds beginning of contour at SkPoint p. More... | |
SkPath & | rMoveTo (SkScalar dx, SkScalar dy) |
Adds beginning of contour relative to last point. More... | |
SkPath & | lineTo (SkScalar x, SkScalar y) |
Adds line from last point to (x, y). More... | |
SkPath & | lineTo (const SkPoint &p) |
Adds line from last point to SkPoint p. More... | |
SkPath & | rLineTo (SkScalar dx, SkScalar dy) |
Adds line from last point to vector (dx, dy). More... | |
SkPath & | quadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) |
Adds quad from last point towards (x1, y1), to (x2, y2). More... | |
SkPath & | quadTo (const SkPoint &p1, const SkPoint &p2) |
Adds quad from last point towards SkPoint p1, to SkPoint p2. More... | |
SkPath & | rQuadTo (SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2) |
Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2). More... | |
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. More... | |
SkPath & | conicTo (const SkPoint &p1, const SkPoint &p2, SkScalar w) |
Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w. More... | |
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. More... | |
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). More... | |
SkPath & | cubicTo (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... | |
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). More... | |
SkPath & | arcTo (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo) |
Appends arc to SkPath. More... | |
SkPath & | arcTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius) |
Appends arc to SkPath, after appending line if needed. More... | |
SkPath & | arcTo (const SkPoint p1, const SkPoint p2, SkScalar radius) |
Appends arc to SkPath, after appending line if needed. More... | |
SkPath & | arcTo (SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkScalar x, SkScalar y) |
Appends arc to SkPath. More... | |
SkPath & | arcTo (const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, const SkPoint xy) |
Appends arc to SkPath. More... | |
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. More... | |
SkPath & | close () |
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... | |
SkPath & | addRect (const SkRect &rect, SkPathDirection dir, unsigned start) |
Adds a new contour to the path, defined by the rect, and wound in the specified direction. More... | |
SkPath & | addRect (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW) |
SkPath & | addRect (SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, SkPathDirection dir=SkPathDirection::kCW) |
SkPath & | addOval (const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW) |
Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. More... | |
SkPath & | addOval (const SkRect &oval, SkPathDirection dir, unsigned start) |
Adds oval to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb. More... | |
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. More... | |
SkPath & | addArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle) |
Appends arc to SkPath, as the start of new contour. More... | |
SkPath & | addRoundRect (const SkRect &rect, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW) |
Appends SkRRect to SkPath, creating a new closed contour. More... | |
SkPath & | addRoundRect (const SkRect &rect, const SkScalar radii[], SkPathDirection dir=SkPathDirection::kCW) |
Appends SkRRect to SkPath, creating a new closed contour. More... | |
SkPath & | addRRect (const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW) |
Adds rrect to SkPath, creating a new closed contour. More... | |
SkPath & | addRRect (const SkRRect &rrect, SkPathDirection dir, unsigned start) |
Adds rrect to SkPath, creating a new closed contour. More... | |
SkPath & | addPoly (const SkPoint pts[], int count, bool close) |
Adds contour created from line array, adding (count - 1) line segments. More... | |
SkPath & | addPoly (const std::initializer_list< SkPoint > &list, bool close) |
Adds contour created from list. More... | |
SkPath & | addPath (const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode) |
Appends src to SkPath, offset by (dx, dy). More... | |
SkPath & | addPath (const SkPath &src, AddPathMode mode=kAppend_AddPathMode) |
Appends src to SkPath. More... | |
SkPath & | addPath (const SkPath &src, const SkMatrix &matrix, AddPathMode mode=kAppend_AddPathMode) |
Appends src to SkPath, transformed by matrix. More... | |
SkPath & | reverseAddPath (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... | |
SkPath | makeTransform (const SkMatrix &m, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const |
SkPath | makeScale (SkScalar sx, SkScalar sy) |
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 dumpAsHex) const |
Writes text representation of SkPath to stream. More... | |
void | dump () const |
void | dumpHex () const |
void | dumpArrays (SkWStream *stream, bool dumpAsHex) const |
void | dumpArrays () const |
size_t | writeToMemory (void *buffer) const |
Writes SkPath to buffer, returning the number of bytes written. More... | |
sk_sp< SkData > | serialize () 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 SkPath | Make (const SkPoint[], int pointCount, const uint8_t[], int verbCount, const SkScalar[], int conicWeightCount, SkPathFillType, bool isVolatile=false) |
Create a new path with the specified segments. More... | |
static SkPath | Rect (const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0) |
static SkPath | Oval (const SkRect &, SkPathDirection=SkPathDirection::kCW) |
static SkPath | Oval (const SkRect &, SkPathDirection, unsigned startIndex) |
static SkPath | Circle (SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW) |
static SkPath | RRect (const SkRRect &, SkPathDirection dir=SkPathDirection::kCW) |
static SkPath | RRect (const SkRRect &, SkPathDirection, unsigned startIndex) |
static SkPath | RRect (const SkRect &bounds, SkScalar rx, SkScalar ry, SkPathDirection dir=SkPathDirection::kCW) |
static SkPath | Polygon (const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false) |
static SkPath | Polygon (const std::initializer_list< SkPoint > &list, bool isClosed, SkPathFillType fillType=SkPathFillType::kWinding, bool isVolatile=false) |
static SkPath | Line (const SkPoint a, const SkPoint b) |
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 | SkPathBuilder |
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... | |
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.
using SkPath::sk_is_trivially_relocatable = std::true_type |
enum SkPath::AddPathMode |
enum SkPath::ArcSize |
enum SkPath::SegmentMask |
enum SkPath::Verb |
SkPath::SkPath | ( | ) |
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.
path | SkPath to copy by value |
SkPath::~SkPath | ( | ) |
Releases ownership of any shared data and deletes data if SkPath is sole owner.
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.
oval | bounds of ellipse containing arc |
startAngle | starting angle of arc in degrees |
sweepAngle | sweep, in degrees. Positive is clockwise; treated modulo 360 |
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.
x | center of circle |
y | center of circle |
radius | distance from center to edge |
dir | SkPath::Direction to wind circle |
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.
oval | bounds of ellipse added |
dir | SkPath::Direction to wind ellipse |
start | index of initial point of ellipse |
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.
oval | bounds of ellipse added |
dir | SkPath::Direction to wind ellipse |
|
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.
src | SkPath verbs, SkPoint, and conic weights to add |
mode | kAppend_AddPathMode or kExtend_AddPathMode |
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.
src | SkPath verbs, SkPoint, and conic weights to add |
matrix | transform applied to src |
mode | kAppend_AddPathMode or kExtend_AddPathMode |
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.
src | SkPath verbs, SkPoint, and conic weights to add |
dx | offset added to src SkPoint array x-axis coordinates |
dy | offset added to src SkPoint array y-axis coordinates |
mode | kAppend_AddPathMode or kExtend_AddPathMode |
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.
pts | array of line sharing end and start SkPoint |
count | length of SkPoint array |
close | true to add line connecting contour end and start |
|
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.
list | array of SkPoint |
close | true to add line connecting contour end and start |
SkPath& SkPath::addRect | ( | const SkRect & | rect, |
SkPathDirection | dir, | ||
unsigned | start | ||
) |
Adds a new contour to the path, defined by the rect, and wound in the specified direction.
The verbs added to the path will be:
kMove, kLine, kLine, kLine, kClose
start specifies which corner to begin the contour: 0: upper-left corner 1: upper-right corner 2: lower-right corner 3: lower-left corner
This start point also acts as the implied beginning of the subsequent, contour, if it does not have an explicit moveTo(). e.g.
path.addRect(...)
if we don't say moveTo() here, we will use the rect's start point path.lineTo(...)
rect | SkRect to add as a closed contour |
dir | SkPath::Direction to orient the new contour |
start | initial corner of SkRect to add |
|
inline |
|
inline |
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.
rect | bounds of SkRRect |
radii | array of 8 SkScalar values, a radius pair for each corner |
dir | SkPath::Direction to wind SkRRect |
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.
rect | bounds of SkRRect |
rx | x-axis radius of rounded corners on the SkRRect |
ry | y-axis radius of rounded corners on the SkRRect |
dir | SkPath::Direction to wind SkRRect |
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.
rrect | bounds and radii of rounded rectangle |
dir | SkPath::Direction to wind SkRRect |
start | index of initial point of SkRRect |
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.
rrect | bounds and radii of rounded rectangle |
dir | SkPath::Direction to wind SkRRect |
size_t SkPath::approximateBytesUsed | ( | ) | const |
Returns the approximate byte size of the SkPath in memory.
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.
p1 | SkPoint common to pair of tangents |
p2 | end of second tangent |
radius | distance from arc to circle center |
|
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.
r | radii on axes before x-axis rotation |
xAxisRotate | x-axis rotation in degrees; positive values are clockwise |
largeArc | chooses smaller or larger arc |
sweep | chooses clockwise or counterclockwise arc |
xy | end of arc |
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.
oval | bounds of ellipse containing arc |
startAngle | starting angle of arc in degrees |
sweepAngle | sweep, in degrees. Positive is clockwise; treated modulo 360 |
forceMoveTo | true to start a new contour with arc |
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.
rx | radius on x-axis before x-axis rotation |
ry | radius on y-axis before x-axis rotation |
xAxisRotate | x-axis rotation in degrees; positive values are clockwise |
largeArc | chooses smaller or larger arc |
sweep | chooses clockwise or counterclockwise arc |
x | end of arc |
y | end of arc |
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.
x1 | x-axis value common to pair of tangents |
y1 | y-axis value common to pair of tangents |
x2 | x-axis value end of second tangent |
y2 | y-axis value end of second tangent |
radius | distance from arc to circle center |
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
|
static |
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.
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.
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.
p1 | control SkPoint of added conic |
p2 | end SkPoint of added conic |
w | weight of added conic |
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.
x1 | control SkPoint of conic on x-axis |
y1 | control SkPoint of conic on y-axis |
x2 | end SkPoint of conic on x-axis |
y2 | end SkPoint of conic on y-axis |
w | weight of added conic |
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.
rect | SkRect, line, or SkPoint checked for containment |
example: https://fiddle.skia.org/c/@Path_conservativelyContainsRect
|
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.
p0 | conic start SkPoint |
p1 | conic control SkPoint |
p2 | conic end SkPoint |
w | conic weight |
pts | storage for quad array |
pow2 | quad count, as power of two, normally 0 to 5 (1 to 32 quad curves) |
int SkPath::countPoints | ( | ) | const |
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.
|
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.
p1 | first control SkPoint of cubic |
p2 | second control SkPoint of cubic |
p3 | end SkPoint of cubic |
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.
x1 | first control SkPoint of cubic on x-axis |
y1 | first control SkPoint of cubic on y-axis |
x2 | second control SkPoint of cubic on x-axis |
y2 | second control SkPoint of cubic on y-axis |
x3 | end SkPoint of cubic on x-axis |
y3 | end SkPoint of cubic on y-axis |
|
inline |
void SkPath::dump | ( | SkWStream * | stream, |
bool | dumpAsHex | ||
) | const |
Writes text representation of SkPath to stream.
If stream is nullptr, writes to standard output. Set dumpAsHex true to generate exact binary representations of floating point numbers used in SkPoint array and conic weights.
stream | writable SkWStream receiving SkPath text representation; may be nullptr |
dumpAsHex | true if SkScalar values are written as hexadecimal |
example: https://fiddle.skia.org/c/@Path_dump
|
inline |
void SkPath::dumpArrays | ( | SkWStream * | stream, |
bool | dumpAsHex | ||
) | const |
|
inline |
const SkRect& SkPath::getBounds | ( | ) | const |
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.
|
inline |
Returns SkPathFillType, the rule used to fill SkPath.
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.
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.
lastPt | storage for final SkPoint in SkPoint array; may be nullptr |
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.
index | SkPoint array element selector |
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.
points | storage for SkPath SkPoint array. May be nullptr |
max | maximum to copy; must be greater than or equal to zero |
uint32_t SkPath::getSegmentMasks | ( | ) | const |
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.
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.
verbs | storage for verbs, may be nullptr |
max | maximum number to copy into verbs |
void SkPath::incReserve | ( | int | extraPtCount | ) |
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().
ending | SkPoint array averaged with this SkPoint array |
weight | contribution of this SkPoint array, and one minus contribution of ending SkPoint array |
out | SkPath replaced by interpolated averages |
bool SkPath::isConvex | ( | ) | const |
Returns true if the path is convex.
If necessary, it will first compute the convexity.
|
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.
p1 | cubic start point |
p2 | cubic control point 1 |
p3 | cubic control point 2 |
p4 | cubic end point |
exact | if 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 |
bool SkPath::isEmpty | ( | ) | const |
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.
bool SkPath::isFinite | ( | ) | const |
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.
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.
compare | SkPath to compare |
|
inline |
Returns if FillType describes area outside SkPath geometry.
The inverse fill area extends indefinitely.
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.
example: https://fiddle.skia.org/c/@Path_isLastContourClosed
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.
line | storage for line. May be nullptr |
|
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.
p1 | line start point |
p2 | line end point |
exact | if false, allow nearly equals |
bool SkPath::isOval | ( | SkRect * | bounds | ) | const |
|
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.
p1 | quad start point |
p2 | quad control point |
p3 | quad end point |
exact | if 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 |
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.
bool SkPath::isRRect | ( | SkRRect * | rrect | ) | const |
bool SkPath::isValid | ( | ) | 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.
|
inlinestatic |
|
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.
p | end SkPoint of added line |
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.
x | end of added line on x-axis |
y | end of added line on y-axis |
|
static |
Create a new path with the specified segments.
The points and weights arrays are read in order, based on the sequence of verbs.
Move 1 point Line 1 point Quad 2 points Conic 2 points and 1 weight Cubic 3 points Close 0 points
If an illegal sequence of verbs is encountered, or the specified number of points or weights is not sufficient given the verbs, an empty Path is returned.
A legal sequence of verbs consists of any number of Contours. A contour always begins with a Move verb, followed by 0 or more segments: Line, Quad, Conic, Cubic, followed by an optional Close.
|
inline |
|
inline |
Adds beginning of contour at SkPoint (x, y).
x | x-axis value of contour start |
y | y-axis value of contour start |
Offsets SkPoint array by (dx, dy).
SkPath is replaced by offset data.
dx | offset added to SkPoint array x-axis coordinates |
dy | offset added to SkPoint array y-axis coordinates |
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.
path | verb array, SkPoint array, weights, and SkPath::FillType to copy |
|
static |
|
static |
|
static |
|
inlinestatic |
|
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.
p1 | control SkPoint of added quad |
p2 | end SkPoint of added quad |
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.
x1 | control SkPoint of quad on x-axis |
y1 | control SkPoint of quad on y-axis |
x2 | end SkPoint of quad on x-axis |
y2 | end SkPoint of quad on y-axis |
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.
rx | radius before x-axis rotation |
ry | radius before x-axis rotation |
xAxisRotate | x-axis rotation in degrees; positive values are clockwise |
largeArc | chooses smaller or larger arc |
sweep | chooses clockwise or counterclockwise arc |
dx | x-axis offset end of arc from last SkPath SkPoint |
dy | y-axis offset end of arc from last SkPath SkPoint |
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".
dx1 | offset from last point to conic control on x-axis |
dy1 | offset from last point to conic control on y-axis |
dx2 | offset from last point to conic end on x-axis |
dy2 | offset from last point to conic end on y-axis |
w | weight of added conic |
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".
dx1 | offset from last point to first cubic control on x-axis |
dy1 | offset from last point to first cubic control on y-axis |
dx2 | offset from last point to second cubic control on x-axis |
dy2 | offset from last point to second cubic control on y-axis |
dx3 | offset from last point to cubic end on x-axis |
dy3 | offset from last point to cubic end on y-axis |
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.
buffer | storage for SkPath |
length | buffer size in bytes; must be multiple of 4 |
|
static |
SkPath& SkPath::reset | ( | ) |
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.
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".
dx | offset from last point to line end on x-axis |
dy | offset from last point to line end on y-axis |
example: https://fiddle.skia.org/c/@Path_rLineTo example: https://fiddle.skia.org/c/@Quad_a example: https://fiddle.skia.org/c/@Quad_b
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".
dx | offset from last point to contour start on x-axis |
dy | offset from last point to contour start on y-axis |
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".
dx1 | offset from last point to quad control on x-axis |
dy1 | offset from last point to quad control on y-axis |
dx2 | offset from last point to quad end on x-axis |
dy2 | offset from last point to quad end on y-axis |
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
|
static |
|
static |
|
static |
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.
|
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.
|
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 Skia to attach a cache of data which speeds repeated drawing.
Mark temporary paths, discarded or modified after use, as volatile to inform Skia 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.
isVolatile | true if caller will alter SkPath after drawing |
|
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.
p | set value of last point |
Sets last point to (x, y).
If SkPoint array is empty, append kMove_Verb to verb array and append (x, y) to SkPoint array.
x | set x-axis value of last point |
y | set y-axis value of last point |
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().
other | SkPath exchanged by value |
example: https://fiddle.skia.org/c/@Path_swap
|
inline |
Replaces FillType with its inverse.
The inverse of FillType describes the area unmodified by the original FillType.
|
inline |
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.
|
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.
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.
buffer | storage for SkPath; may be nullptr |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |