class SkPathData; class SkRRect; struct SkPathRaw; class SkString;
// todo: add this flag to clients #ifndef SK_SUPPORT_LEGACY_PATHBUILDER_SETLASTPT #define SK_SUPPORT_LEGACY_PATHBUILDER_SETLASTPT #endif
class SK_API SkPathBuilder {
using PointsArray = skia_private::STArray<4, SkPoint>;
using VerbsArray = skia_private::STArray<4, SkPathVerb>;
using ConicWeightsArray = skia_private::STArray<2, float>;
public: /** Constructs an empty SkPathBuilder. By default, SkPathBuilder has no verbs, no SkPoint, and noweights.FillTypeissettokWinding.
/** Like computeFiniteBounds() but returns a 'tight' bounds, meaning when there are curve *segments,thiscomputestheX/Ylimitsofthecurveitself,notthecurve'scontrol *point(s).Forapolygon,thisreturnsthesameascomputeFiniteBounds().
*/
std::optional<SkRect> computeTightBounds() const;
// DEPRECATED -- returns "empty" if the bounds are non-finite
SkRect computeBounds() const { if (auto bounds = this->computeFiniteBounds()) { return *bounds;
} return SkRect::MakeEmpty();
}
/** Returns an SkPath representing the current state of the SkPathBuilder. The builder is unchangedafterreturningthepath.
/** Specifies whether SkPath is volatile; whether it will be altered or discarded bythecallerafteritisdrawn.SkPathbydefaulthavevolatilesetfalse,allowing Skiatoattachacacheofdatawhichspeedsrepeateddrawing.
/** Sets SkPathBuilder to its initial state. Removesverbarray,SkPointarray,andweights,andsetsFillTypetokWinding. InternalstorageassociatedwithSkPathBuilderispreserved.
/** Specifies the beginning of contour. If the previous verb was a "move" verb, *thenthisjustreplacesthepointvalueofthatmove,otherwiseitappendsanew *"move"verbtothebuilderusingthepoint. * *Thus,eachcontourcanonlyhave1moveverbinit(thelastonespecified).
*/
SkPathBuilder& moveTo(SkPoint point);
/** Adds quad from last point towards SkPoint p1, to SkPoint p2. IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointissetto(0,0) beforeaddingquad.
/** Adds quad from last point towards the first SkPoint in pts, to the second. IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointissetto(0,0) beforeaddingquad.
/** Adds conic from last point towards pt1, to pt2, weighted by w. IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointissetto(0,0) beforeaddingconic.
/** Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w. IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointissetto(0,0) beforeaddingconic.
/** Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w. IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointissetto(0,0) beforeaddingconic.
/** Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at SkPointp3.IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointis setto(0,0)beforeaddingcubic.
/** Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3,y3).IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointisset to(0,0)beforeaddingcubic.
/** Adds cubic from last point towards the first SkPoint, then towards the second, ending at thethird.IfSkPathBuilderisempty,orlastSkPath::VerbiskClose_Verb,lastpointis setto(0,0)beforeaddingcubic.
/** Appends kClose_Verb to SkPathBuilder. A closed contour connects the first and last SkPoint withline,formingacontinuousloop.Openandclosedcontourdrawthesame withSkPaint::kFill_Style.WithSkPaint::kStroke_Style,opencontourdraws SkPaint::Capatcontourstartandend;closedcontourdraws SkPaint::Joinatcontourstartandend.
// Relative versions of segments, relative to the previous position.
/** Adds beginning of contour relative to last point. IfSkPathBuilderisempty,startscontourat(dx,dy). Otherwise,startcontouratlastpointoffsetby(dx,dy). Functionnamestandsfor"relativemoveto".
/** Adds beginning of contour relative to last point. IfSkPathBuilderisempty,startscontourat(dx,dy). Otherwise,startcontouratlastpointoffsetby(dx,dy). Functionnamestandsfor"relativemoveto".
/** Adds line from last point to vector given by pt. If SkPathBuilder is empty, or last SkPath::VerbiskClose_Verb,lastpointissetto(0,0)beforeaddingline.
/** Adds quad from last point towards vector pt1, to vector pt2. IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingquad.
/** Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2). IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingquad.
/** Adds conic from last point towards vector p1, to vector p2, weightedbyw.IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingconic.
/** Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weightedbyw.IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingconic.
/** Adds cubic from last point towards vector pt1, then towards vectorpt2,tovectorpt3. IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingcubic.
/** Adds cubic from last point towards vector (dx1, dy1), then towards vector(dx2,dy2),tovector(dx3,dy3). IfSkPathBuilderisempty,orlastSkPath::Verb iskClose_Verb,lastpointissetto(0,0)beforeaddingcubic.
enum ArcSize {
kSmall_ArcSize, //!< smaller of arc pair
kLarge_ArcSize, //!< larger of arc pair
};
/** Appends arc to SkPathBuilder, relative to last SkPath SkPoint. Arc is implemented by one or moreconic,weightedtodescribepartofovalwithradii(rx,ry)rotatedby xAxisRotatedegrees.ArccurvesfromlastSkPathBuilderSkPointtorelativeendSkPoint: (dx,dy),choosingoneoffourpossibleroutes:clockwiseor counterclockwise,andsmallerorlarger.IfSkPathBuilderisempty,thestartarcSkPoint is(0,0).
/** Appends arc to the builder. Arc added is part of ellipse boundedbyoval,fromstartAnglethroughsweepAngle.BothstartAngleand sweepAnglearemeasuredindegrees,wherezerodegreesisalignedwiththe positivex-axis,andpositivesweepsextendsarcclockwise.
/** Appends arc to SkPath, after appending line if needed. Arc is implemented by conic weightedtodescribepartofcircle.Arciscontainedbytangentfrom lastSkPathpointtop1,andtangentfromp1top2.Arc ispartofcirclesizedtoradius,positionedsoittouchesbothtangentlines.
/** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe partofovalwithradii(r.fX,r.fY)rotatedbyxAxisRotatedegrees.Arccurves fromlastSkPathSkPointto(xy.fX,xy.fY),choosingoneoffourpossibleroutes: clockwiseorcounterclockwise, andsmallerorlarger.
/** Appends arc to the builder, as the start of new contour. Arc added is part of ellipse boundedbyoval,fromstartAnglethroughsweepAngle.BothstartAngleand sweepAnglearemeasuredindegrees,wherezerodegreesisalignedwiththe positivex-axis,andpositivesweepsextendsarcclockwise.
/** Adds oval to SkPathBuilder, appending kMove_Verb, four kConic_Verb, and kClose_Verb. OvalisuprightellipseboundedbySkRectovalwithradiiequaltohalfovalwidth andhalfovalheight.Ovalbeginsat(oval.fRight,oval.centerY())andcontinues clockwiseifdiriskCW_Direction,counterclockwiseifdiriskCCW_Direction.
/** Appends SkRRect to SkPathBuilder, creating a new closed contour. If dir is kCW_Direction, SkRRectwindsclockwise.IfdiriskCCW_Direction,SkRRectwindscounterclockwise.
/** Appends SkRRect to SkPathBuilder, creating a new closed contour. If dir is kCW_Direction, SkRRectstartsattop-leftofthelower-leftcornerandwindsclockwise.Ifdiris kCCW_Direction,SkRRectstartsatthebottom-leftoftheupper-leftcornerandwinds counterclockwise.
/** Adds oval to SkPathBuilder, appending kMove_Verb, four kConic_Verb, and kClose_Verb. OvalisuprightellipseboundedbySkRectovalwithradiiequaltohalfovalwidth andhalfovalheight.Ovalbeginsatstartandcontinues clockwiseifdiriskCW_Direction,counterclockwiseifdiriskCCW_Direction.
/** Adds circle with center and radius to SkPathBuilder, appending kMove_Verb, fourkConic_Verb,andkClose_Verb.Circlebeginsat:(center.fX+radius,center.fY).
Hasnoeffectifradiusiszeroornegative.
@paramcentercenterofcircle @paramradiusdistancefromcentertoedge @paramdirSkPath::Directiontowindcircle @returnreferencetoSkPathBuilder
*/
SkPathBuilder& addCircle(SkPoint center, float radius,
SkPathDirection dir = SkPathDirection::kDefault);
SkPathBuilder& addCircle(float x, float y, float radius,
SkPathDirection dir = SkPathDirection::kDefault) { return this->addCircle({x, y}, radius, dir);
}
/** Adds contour created from line array, adding (pts.size() - 1) line segments. Contouraddedstartsatpts[0],thenaddsalineforeveryadditionalSkPoint inptsarray.Ifcloseistrue,appendskClose_VerbtoSkPath,connecting pts[count-1]andpts[0].
/** Replaces SkPathFillType with its inverse. The inverse of SkPathFillType describes the area unmodifiedbytheoriginalSkPathFillType.
*/
SkPathBuilder& toggleInverseFillType() {
fFillType = SkPathFillType_ToggleInverse(fFillType); return *this;
}
/** Returns if SkPath is empty. EmptySkPathBuildermayhaveFillTypebuthasnoSkPoint,SkPath::Verb,orconicweight. SkPathBuilder()constructsemptySkPathBuilder;reset()andrewind()makeSkPathempty.
/** Change the point at the specified index (see countPoints()). *Ifindexisoutofrange,thecalldoesnothing. * *@paramindexwhichpointtoreplace *@parampthenewpointvalue
*/ void setPoint(size_t index, SkPoint p);
/** Change the last point in the builder. *Ifthebuilderisempty,thecalldoesnothing. * *@parampthenewpointvalue
*/ void setLastPoint(SkPoint p) {
this->setPoint(this->points().size() - 1, p);
}
#ifdef SK_SUPPORT_LEGACY_PATHBUILDER_SETLASTPT /** DEPRECATED: use setLastPoint() or setPoint() Setsthelastpointonthepath.IfSkPointarrayisempty,thisbehaveslikemoveTo().
enumclass Reserve { // Reserves the exact amount of storage needed for pathraw (never overallocates).
kExact, // Allows the storage buffers to overallocate, based on their internal growth policy.
kGrow
};
SkPathBuilder& addRaw(const SkPathRaw&, Reserve);
SkPathIter iter() const;
enumclass DumpFormat {
kDecimal,
kHex,
};
SkString dumpToString(DumpFormat = DumpFormat::kDecimal) const; void dump(DumpFormat) const; // can't use default argument easily in debugger, so we name this // helper explicitly. void dump() const { this->dump(DumpFormat::kDecimal); }
// called right before we add a (non-move) verb void ensureMove() {
fType = SkPathIsAType::kGeneral; if (fVerbs.empty()) {
this->moveTo({0, 0});
} elseif (fVerbs.back() == SkPathVerb::kClose) {
this->moveTo(fPts[fLastMoveIndex]);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.