Skia
2D Graphics Library
SkPathBuilder Class Reference

#include <SkPathBuilder.h>

Public Types

enum  ArcSize { kSmall_ArcSize, kLarge_ArcSize }
 

Public Member Functions

 SkPathBuilder ()
 
 ~SkPathBuilder ()
 
SkPath snapshot ()
 
SkPath detach ()
 
SkPathBuildersetFillType (SkPathFillType ft)
 
SkPathBuildersetIsVolatile (bool isVolatile)
 
SkPathBuilderreset ()
 
SkPathBuildermoveTo (SkPoint pt)
 
SkPathBuildermoveTo (SkScalar x, SkScalar y)
 
SkPathBuilderlineTo (SkPoint pt)
 
SkPathBuilderlineTo (SkScalar x, SkScalar y)
 
SkPathBuilderquadTo (SkPoint pt1, SkPoint pt2)
 
SkPathBuilderquadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 
SkPathBuilderquadTo (const SkPoint pts[2])
 
SkPathBuilderconicTo (SkPoint pt1, SkPoint pt2, SkScalar w)
 
SkPathBuilderconicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 
SkPathBuilderconicTo (const SkPoint pts[2], SkScalar w)
 
SkPathBuildercubicTo (SkPoint pt1, SkPoint pt2, SkPoint pt3)
 
SkPathBuildercubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 
SkPathBuildercubicTo (const SkPoint pts[3])
 
SkPathBuilderclose ()
 
SkPathBuilderrLineTo (SkPoint pt)
 
SkPathBuilderrLineTo (SkScalar x, SkScalar y)
 
SkPathBuilderrQuadTo (SkPoint pt1, SkPoint pt2)
 
SkPathBuilderrQuadTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 
SkPathBuilderrConicTo (SkPoint p1, SkPoint p2, SkScalar w)
 
SkPathBuilderrConicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
 
SkPathBuilderrCubicTo (SkPoint pt1, SkPoint pt2, SkPoint pt3)
 
SkPathBuilderrCubicTo (SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 
SkPathBuilderarcTo (const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
 Appends arc to the builder. More...
 
SkPathBuilderarcTo (SkPoint p1, SkPoint p2, SkScalar radius)
 Appends arc to SkPath, after appending line if needed. More...
 
SkPathBuilderarcTo (SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkPoint xy)
 Appends arc to SkPath. More...
 
SkPathBuilderaddArc (const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg)
 Appends arc to the builder, as the start of new contour. More...
 
SkPathBuilderaddRect (const SkRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddOval (const SkRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddRRect (const SkRRect &, SkPathDirection, unsigned startIndex)
 
SkPathBuilderaddRect (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddOval (const SkRect &rect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddRRect (const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddCircle (SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
 
SkPathBuilderaddPolygon (const SkPoint pts[], int count, bool isClosed)
 
SkPathBuilderaddPolygon (const std::initializer_list< SkPoint > &list, bool isClosed)
 
void incReserve (int extraPtCount, int extraVerbCount)
 
void incReserve (int extraPtCount)
 

Member Enumeration Documentation

◆ ArcSize

Enumerator
kSmall_ArcSize 

smaller of arc pair

kLarge_ArcSize 

larger of arc pair

Constructor & Destructor Documentation

◆ SkPathBuilder()

SkPathBuilder::SkPathBuilder ( )

◆ ~SkPathBuilder()

SkPathBuilder::~SkPathBuilder ( )

Member Function Documentation

◆ addArc()

SkPathBuilder& SkPathBuilder::addArc ( const SkRect oval,
SkScalar  startAngleDeg,
SkScalar  sweepAngleDeg 
)

Appends arc to the builder, 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
startAngleDegstarting angle of arc in degrees
sweepAngleDegsweep, in degrees. Positive is clockwise; treated modulo 360
Returns
reference to this builder

◆ addCircle()

SkPathBuilder& SkPathBuilder::addCircle ( SkScalar  center_x,
SkScalar  center_y,
SkScalar  radius,
SkPathDirection  dir = SkPathDirection::kCW 
)

◆ addOval() [1/2]

SkPathBuilder& SkPathBuilder::addOval ( const SkRect ,
SkPathDirection  ,
unsigned  startIndex 
)

◆ addOval() [2/2]

SkPathBuilder& SkPathBuilder::addOval ( const SkRect rect,
SkPathDirection  dir = SkPathDirection::kCW 
)
inline

◆ addPolygon() [1/2]

SkPathBuilder& SkPathBuilder::addPolygon ( const SkPoint  pts[],
int  count,
bool  isClosed 
)

◆ addPolygon() [2/2]

SkPathBuilder& SkPathBuilder::addPolygon ( const std::initializer_list< SkPoint > &  list,
bool  isClosed 
)
inline

◆ addRect() [1/2]

SkPathBuilder& SkPathBuilder::addRect ( const SkRect ,
SkPathDirection  ,
unsigned  startIndex 
)

◆ addRect() [2/2]

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

◆ addRRect() [1/2]

SkPathBuilder& SkPathBuilder::addRRect ( const SkRRect ,
SkPathDirection  ,
unsigned  startIndex 
)

◆ addRRect() [2/2]

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

◆ arcTo() [1/3]

SkPathBuilder& SkPathBuilder::arcTo ( const SkRect oval,
SkScalar  startAngleDeg,
SkScalar  sweepAngleDeg,
bool  forceMoveTo 
)

Appends arc to the builder.

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 the builder's last point to initial arc point if forceMoveTo is false and the builder 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
startAngleDegstarting angle of arc in degrees
sweepAngleDegsweep, in degrees. Positive is clockwise; treated modulo 360
forceMoveTotrue to start a new contour with arc
Returns
reference to the builder

◆ arcTo() [2/3]

SkPathBuilder& SkPathBuilder::arcTo ( SkPoint  p1,
SkPoint  p2,
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 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() [3/3]

SkPathBuilder& SkPathBuilder::arcTo ( SkPoint  r,
SkScalar  xAxisRotate,
ArcSize  largeArc,
SkPathDirection  sweep,
SkPoint  xy 
)

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

SkPathBuilder& SkPathBuilder::close ( )

◆ conicTo() [1/3]

SkPathBuilder& SkPathBuilder::conicTo ( SkPoint  pt1,
SkPoint  pt2,
SkScalar  w 
)

◆ conicTo() [2/3]

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

◆ conicTo() [3/3]

SkPathBuilder& SkPathBuilder::conicTo ( const SkPoint  pts[2],
SkScalar  w 
)
inline

◆ cubicTo() [1/3]

SkPathBuilder& SkPathBuilder::cubicTo ( SkPoint  pt1,
SkPoint  pt2,
SkPoint  pt3 
)

◆ cubicTo() [2/3]

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

◆ cubicTo() [3/3]

SkPathBuilder& SkPathBuilder::cubicTo ( const SkPoint  pts[3])
inline

◆ detach()

SkPath SkPathBuilder::detach ( )

◆ incReserve() [1/2]

void SkPathBuilder::incReserve ( int  extraPtCount,
int  extraVerbCount 
)

◆ incReserve() [2/2]

void SkPathBuilder::incReserve ( int  extraPtCount)
inline

◆ lineTo() [1/2]

SkPathBuilder& SkPathBuilder::lineTo ( SkPoint  pt)

◆ lineTo() [2/2]

SkPathBuilder& SkPathBuilder::lineTo ( SkScalar  x,
SkScalar  y 
)
inline

◆ moveTo() [1/2]

SkPathBuilder& SkPathBuilder::moveTo ( SkPoint  pt)

◆ moveTo() [2/2]

SkPathBuilder& SkPathBuilder::moveTo ( SkScalar  x,
SkScalar  y 
)
inline

◆ quadTo() [1/3]

SkPathBuilder& SkPathBuilder::quadTo ( SkPoint  pt1,
SkPoint  pt2 
)

◆ quadTo() [2/3]

SkPathBuilder& SkPathBuilder::quadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)
inline

◆ quadTo() [3/3]

SkPathBuilder& SkPathBuilder::quadTo ( const SkPoint  pts[2])
inline

◆ rConicTo() [1/2]

SkPathBuilder& SkPathBuilder::rConicTo ( SkPoint  p1,
SkPoint  p2,
SkScalar  w 
)

◆ rConicTo() [2/2]

SkPathBuilder& SkPathBuilder::rConicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  w 
)
inline

◆ rCubicTo() [1/2]

SkPathBuilder& SkPathBuilder::rCubicTo ( SkPoint  pt1,
SkPoint  pt2,
SkPoint  pt3 
)

◆ rCubicTo() [2/2]

SkPathBuilder& SkPathBuilder::rCubicTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2,
SkScalar  x3,
SkScalar  y3 
)
inline

◆ reset()

SkPathBuilder& SkPathBuilder::reset ( )

◆ rLineTo() [1/2]

SkPathBuilder& SkPathBuilder::rLineTo ( SkPoint  pt)

◆ rLineTo() [2/2]

SkPathBuilder& SkPathBuilder::rLineTo ( SkScalar  x,
SkScalar  y 
)
inline

◆ rQuadTo() [1/2]

SkPathBuilder& SkPathBuilder::rQuadTo ( SkPoint  pt1,
SkPoint  pt2 
)

◆ rQuadTo() [2/2]

SkPathBuilder& SkPathBuilder::rQuadTo ( SkScalar  x1,
SkScalar  y1,
SkScalar  x2,
SkScalar  y2 
)
inline

◆ setFillType()

SkPathBuilder& SkPathBuilder::setFillType ( SkPathFillType  ft)
inline

◆ setIsVolatile()

SkPathBuilder& SkPathBuilder::setIsVolatile ( bool  isVolatile)
inline

◆ snapshot()

SkPath SkPathBuilder::snapshot ( )

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