IndexGeometriesBLPath
BLPath Class Reference

2D vector path [C++ API].

Classes

Member Functions

Construction & Destruction
Overloaded Operators
Common Functionality
Accessors
Path Construction
Adding Multiple Segments

Adding multiple segments API was designed to provide high-performance path building in case that the user knows the segments that will be added to the path in advance.

Adding Figures

Adding a figure means starting with a move-to segment. For example addBox() would start a new figure by adding BL_PATH_CMD_MOVE_TO segment, and then by adding 3 lines, and finally a close command.

Adding Paths
Manipulation
Transformations
Equality & Comparison
Path Information
Hit Testing

Additional Inherited Members

- Public Attributes inherited from BLObjectCore

bool BLPath::empty() constnoexcept[¶]

Tests whether the path is empty, which means its size equals to zero.

size_t BLPath::size() constnoexcept[¶]

Returns path size (count of vertices used).

size_t BLPath::capacity() constnoexcept[¶]

Returns path capacity (count of allocated vertices).

const BLPoint* BLPath::vertexData() constnoexcept[¶]

Returns path's vertex data (read-only).

const BLPoint* BLPath::vertexDataEnd() constnoexcept[¶]

Returns the end of path's vertex data (read-only).

const uint8_t* BLPath::commandData() constnoexcept[¶]

Returns path's command data (read-only).

const uint8_t* BLPath::commandDataEnd() constnoexcept[¶]

Returns the end of path's command data (read-only).

BLPathView BLPath::view() constnoexcept[¶]

Returns a read-only path data as BLPathView.

BLResult BLPath::clear()noexcept[¶]

Clears the content of the path.

BLResult BLPath::shrink()noexcept[¶]

Shrinks the capacity of the path to fit the current usage.

BLResult BLPath::reserve(
size_t n
)noexcept[¶]

Reserves the capacity of the path for at least n vertices and commands.

BLResult BLPath::setVertexAt(
size_t index,
uint32_t cmd,
const BLPoint& pt
)noexcept[1/2][¶]

Sets vertex at index to cmd and pt.

Pass BL_PATH_CMD_PRESERVE in cmd to preserve the current command.

BLResult BLPath::setVertexAt(
size_t index,
uint32_t cmd,
double x,
double y
)noexcept[2/2][¶]

Sets vertex at index to cmd and [x, y].

Pass BL_PATH_CMD_PRESERVE in cmd to preserve the current command.

BLResult BLPath::moveTo(
const BLPoint& p0
)noexcept[1/2][¶]

Moves to p0.

Appends BL_PATH_CMD_MOVE[p0] command to the path.

BLResult BLPath::moveTo(
double x0,
double y0
)noexcept[2/2][¶]

Moves to [x0, y0].

Appends BL_PATH_CMD_MOVE[x0, y0] command to the path.

BLResult BLPath::lineTo(
const BLPoint& p1
)noexcept[1/2][¶]

Adds line to p1.

Appends BL_PATH_CMD_ON[p1] command to the path.

BLResult BLPath::lineTo(
double x1,
double y1
)noexcept[2/2][¶]

Adds line to [x1, y1].

Appends BL_PATH_CMD_ON[x1, y1] command to the path.

BLResult BLPath::polyTo(
const BLPoint* poly,
size_t count
)noexcept[¶]

Adds a polyline (LineTo) of the given poly array of size count.

Appends multiple BL_PATH_CMD_ON[x[i], y[i]] commands to the path depending on count parameter.

BLResult BLPath::quadTo(
const BLPoint& p1,
const BLPoint& p2
)noexcept[1/2][¶]

Adds a quadratic curve to p1 and p2.

Appends the following commands to the path:

  • BL_PATH_CMD_QUAD[p1]
  • BL_PATH_CMD_ON[p2]

Matches SVG 'Q' path command:

BLResult BLPath::quadTo(
double x1,
double y1,
double x2,
double y2
)noexcept[2/2][¶]

Adds a quadratic curve to [x1, y1] and [x2, y2].

Appends the following commands to the path:

  • BL_PATH_CMD_QUAD[x1, y1]
  • BL_PATH_CMD_ON[x2, y2]

Matches SVG 'Q' path command:

BLResult BLPath::cubicTo(
const BLPoint& p1,
const BLPoint& p2,
const BLPoint& p3
)noexcept[1/2][¶]

Adds a cubic curve to p1, p2, p3.

Appends the following commands to the path:

  • BL_PATH_CMD_CUBIC[p1]
  • BL_PATH_CMD_CUBIC[p2]
  • BL_PATH_CMD_ON[p3]

Matches SVG 'C' path command:

BLResult BLPath::cubicTo(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3
)noexcept[2/2][¶]

Adds a cubic curve to [x1, y1], [x2, y2], and [x3, y3].

Appends the following commands to the path:

  • BL_PATH_CMD_CUBIC[x1, y1]
  • BL_PATH_CMD_CUBIC[x2, y2]
  • BL_PATH_CMD_ON[x3, y3]

Matches SVG 'C' path command:

BLResult BLPath::smoothQuadTo(
const BLPoint& p2
)noexcept[1/2][¶]

Adds a smooth quadratic curve to p2, calculating p1 from last points.

Appends the following commands to the path:

  • BL_PATH_CMD_QUAD[calculated]
  • BL_PATH_CMD_ON[p2]

Matches SVG 'T' path command:

BLResult BLPath::smoothQuadTo(
double x2,
double y2
)noexcept[2/2][¶]

Adds a smooth quadratic curve to [x2, y2], calculating [x1, y1] from last points.

Appends the following commands to the path:

  • BL_PATH_CMD_QUAD[calculated]
  • BL_PATH_CMD_ON[x2, y2]

Matches SVG 'T' path command:

BLResult BLPath::smoothCubicTo(
const BLPoint& p2,
const BLPoint& p3
)noexcept[1/2][¶]

Adds a smooth cubic curve to p2 and p3, calculating p1 from last points.

Appends the following commands to the path:

  • BL_PATH_CMD_CUBIC[calculated]
  • BL_PATH_CMD_CUBIC[p2]
  • BL_PATH_CMD_ON[p3]

Matches SVG 'S' path command:

BLResult BLPath::smoothCubicTo(
double x2,
double y2,
double x3,
double y3
)noexcept[2/2][¶]

Adds a smooth cubic curve to [x2, y2] and [x3, y3], calculating [x1, y1] from last points.

Appends the following commands to the path:

  • BL_PATH_CMD_CUBIC[calculated]
  • BL_PATH_CMD_CUBIC[x2, y2]
  • BL_PATH_CMD_ON[x3, y3]

Matches SVG 'S' path command:

BLResult BLPath::arcTo(
const BLPoint& c,
const BLPoint& r,
double start,
double sweep,
bool forceMoveTo = false
)noexcept[1/2][¶]

Adds an arc to the path.

The center of the arc is specified by c and radius by r. Both start and sweep angles are in radians. If the last vertex doesn't match the start of the arc then a lineTo() would be emitted before adding the arc. Pass true in forceMoveTo to always emit moveTo() at the beginning of the arc, which starts a new figure.

BLResult BLPath::arcTo(
double cx,
double cy,
double rx,
double ry,
double start,
double sweep,
bool forceMoveTo = false
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::arcQuadrantTo(
const BLPoint& p1,
const BLPoint& p2
)noexcept[1/2][¶]

Adds an arc quadrant (90deg) to the path. The first point p1 specifies the quadrant corner and the last point p2 specifies the end point.

BLResult BLPath::arcQuadrantTo(
double x1,
double y1,
double x2,
double y2
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::ellipticArcTo(
const BLPoint& rp,
double xAxisRotation,
bool largeArcFlag,
bool sweepFlag,
const BLPoint& p1
)noexcept[1/2][¶]

Adds an elliptic arc to the path that follows the SVG specification.

Matches SVG 'A' path command:

BLResult BLPath::ellipticArcTo(
double rx,
double ry,
double xAxisRotation,
bool largeArcFlag,
bool sweepFlag,
double x1,
double y1
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::close()noexcept[¶]

Closes the current figure.

Appends BL_PATH_CMD_CLOSE to the path.

Matches SVG 'Z' path command:

BLResult BLPath::addBox(
const BLBoxI& box,
)noexcept[1/3][¶]

Adds a closed rectangle to the path specified by box.

BLResult BLPath::addBox(
const BLBox& box,
)noexcept[2/3][¶]

Adds a closed rectangle to the path specified by box.

BLResult BLPath::addBox(
double x0,
double y0,
double x1,
double y1,
)noexcept[3/3][¶]

Adds a closed rectangle to the path specified by [x0, y0, x1, y1].

BLResult BLPath::addRect(
const BLRectI& rect,
)noexcept[1/3][¶]

Adds a closed rectangle to the path specified by rect.

BLResult BLPath::addRect(
const BLRect& rect,
)noexcept[2/3][¶]

Adds a closed rectangle to the path specified by rect.

BLResult BLPath::addRect(
double x,
double y,
double w,
double h,
)noexcept[3/3][¶]

Adds a closed rectangle to the path specified by [x, y, w, h].

BLResult BLPath::addGeometry(
BLGeometryType geometryType,
const void* geometryData,
const BLMatrix2D* m = nullptr,
)noexcept[¶]

Adds a geometry to the path.

BLResult BLPath::addCircle(
const BLCircle& circle,
)noexcept[1/2][¶]

Adds a closed circle to the path.

BLResult BLPath::addCircle(
const BLCircle& circle,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addEllipse(
const BLEllipse& ellipse,
)noexcept[1/2][¶]

Adds a closed ellipse to the path.

BLResult BLPath::addEllipse(
const BLEllipse& ellipse,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRoundRect(
const BLRoundRect& rr,
)noexcept[1/2][¶]

Adds a closed rounded rectangle to the path.

BLResult BLPath::addRoundRect(
const BLRoundRect& rr,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addArc(
const BLArc& arc,
)noexcept[1/2][¶]

Adds an unclosed arc to the path.

BLResult BLPath::addArc(
const BLArc& arc,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addChord(
const BLArc& chord,
)noexcept[1/2][¶]

Adds a closed chord to the path.

BLResult BLPath::addChord(
const BLArc& chord,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPie(
const BLArc& pie,
)noexcept[1/2][¶]

Adds a closed pie to the path.

BLResult BLPath::addPie(
const BLArc& pie,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addLine(
const BLLine& line,
)noexcept[1/2][¶]

Adds an unclosed line to the path.

BLResult BLPath::addLine(
const BLLine& line,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addTriangle(
const BLTriangle& triangle,
)noexcept[1/2][¶]

Adds a closed triangle.

BLResult BLPath::addTriangle(
const BLTriangle& triangle,
const BLMatrix2D& transform,
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLArrayView<BLPointI>& poly,
)noexcept[1/8][¶]

Adds a polyline.

BLResult BLPath::addPolyline(
const BLArrayView<BLPointI>& poly,
const BLMatrix2D& transform,
)noexcept[2/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLPointI* poly,
size_t n,
)noexcept[3/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLPointI* poly,
size_t n,
const BLMatrix2D& transform,
)noexcept[4/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLArrayView<BLPoint>& poly,
)noexcept[5/8][¶]

Adds a polyline.

BLResult BLPath::addPolyline(
const BLArrayView<BLPoint>& poly,
const BLMatrix2D& transform,
)[6/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLPoint* poly,
size_t n,
)noexcept[7/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolyline(
const BLPoint* poly,
size_t n,
const BLMatrix2D& transform,
)[8/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLArrayView<BLPointI>& poly,
)noexcept[1/8][¶]

Adds a polygon.

BLResult BLPath::addPolygon(
const BLArrayView<BLPointI>& poly,
const BLMatrix2D& transform,
)noexcept[2/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLPointI* poly,
size_t n,
)noexcept[3/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLPointI* poly,
size_t n,
const BLMatrix2D& transform,
)noexcept[4/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLArrayView<BLPoint>& poly,
)noexcept[5/8][¶]

Adds a polygon.

BLResult BLPath::addPolygon(
const BLArrayView<BLPoint>& poly,
const BLMatrix2D& transform,
)noexcept[6/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLPoint* poly,
size_t n,
)noexcept[7/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPolygon(
const BLPoint* poly,
size_t n,
const BLMatrix2D& transform,
)noexcept[8/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLArrayView<BLBoxI>& array,
)noexcept[1/8][¶]

Adds an array of closed boxes.

BLResult BLPath::addBoxArray(
const BLArrayView<BLBoxI>& array,
const BLMatrix2D& transform,
)noexcept[2/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLBoxI* data,
size_t n,
)noexcept[3/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLBoxI* data,
size_t n,
const BLMatrix2D& transform,
)noexcept[4/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLArrayView<BLBox>& array,
)noexcept[5/8][¶]

Adds an array of closed boxes.

BLResult BLPath::addBoxArray(
const BLArrayView<BLBox>& array,
const BLMatrix2D& transform,
)noexcept[6/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLBox* data,
size_t n,
)noexcept[7/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addBoxArray(
const BLBox* data,
size_t n,
const BLMatrix2D& transform,
)noexcept[8/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLArrayView<BLRectI>& array,
)noexcept[1/8][¶]

Adds an array of closed rectangles.

BLResult BLPath::addRectArray(
const BLArrayView<BLRectI>& array,
const BLMatrix2D& transform,
)noexcept[2/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLRectI* data,
size_t n,
)noexcept[3/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLRectI* data,
size_t n,
const BLMatrix2D& transform,
)noexcept[4/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLArrayView<BLRect>& array,
)noexcept[5/8][¶]

Adds an array of closed rectangles.

BLResult BLPath::addRectArray(
const BLArrayView<BLRect>& array,
const BLMatrix2D& transform,
)noexcept[6/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLRect* data,
size_t n,
)noexcept[7/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addRectArray(
const BLRect* data,
size_t n,
const BLMatrix2D& transform,
)noexcept[8/8][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::addPath(
const BLPath& path
)noexcept[1/6][¶]

Adds other path to this path.

BLResult BLPath::addPath(
const BLPath& path,
const BLRange& range
)noexcept[2/6][¶]

Adds other path sliced by the given range to this path.

BLResult BLPath::addPath(
const BLPath& path,
const BLPoint& p
)noexcept[3/6][¶]

Adds other path translated by p to this path.

BLResult BLPath::addPath(
const BLPath& path,
const BLRange& range,
const BLPoint& p
)noexcept[4/6][¶]

Adds other path translated by p and sliced by the given range to this path.

BLResult BLPath::addPath(
const BLPath& path,
const BLMatrix2D& transform
)noexcept[5/6][¶]

Adds other path transformed by m to this path.

BLResult BLPath::addPath(
const BLPath& path,
const BLRange& range,
const BLMatrix2D& transform
)noexcept[6/6][¶]

Adds other path transformed by m and sliced by the given range to this path.

BLResult BLPath::addReversedPath(
const BLPath& path,
BLPathReverseMode reverseMode
)noexcept[1/2][¶]

Adds other path, but reversed.

BLResult BLPath::addReversedPath(
const BLPath& path,
const BLRange& range,
BLPathReverseMode reverseMode
)noexcept[2/2][¶]

Adds other path, but reversed.

BLResult BLPath::addStrokedPath(
const BLPath& path,
const BLStrokeOptionsCore& strokeOptions,
const BLApproximationOptions& approximationOptions
)noexcept[1/2][¶]

Adds a stroke of path to this path.

BLResult BLPath::addStrokedPath(
const BLPath& path,
const BLRange& range,
const BLStrokeOptionsCore& strokeOptions,
const BLApproximationOptions& approximationOptions
)noexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

BLResult BLPath::translate(
const BLPoint& p
)noexcept[1/2][¶]

Translates the whole path by p.

BLResult BLPath::translate(
const BLRange& range,
const BLPoint& p
)noexcept[2/2][¶]

Translates a part of the path specified by the given range by p.

BLResult BLPath::transform(
const BLMatrix2D& m
)noexcept[1/2][¶]

Transforms the whole path by matrix m.

BLResult BLPath::transform(
const BLRange& range,
const BLMatrix2D& m
)noexcept[2/2][¶]

Transforms a part of the path specified by the given range by matrix m.

BLResult BLPath::fitTo(
const BLRect& rect,
uint32_t fitFlags
)noexcept[1/2][¶]

Fits the whole path into the given rect by taking into account fit flags passed by fitFlags.

BLResult BLPath::fitTo(
const BLRange& range,
const BLRect& rect,
uint32_t fitFlags
)noexcept[2/2][¶]

Fits a path of the path specified by the given range into the given rect by taking into account fit flags passed by fitFlags.

bool BLPath::equals(
const BLPath& other
) constnoexcept[¶]

Tests whether this path and the other path are equal.

The equality check is deep. The data of both paths is examined and binary compared (thus a slight difference like -0 and +0 would make the equality check to fail).

BLResult BLPath::getInfoFlags(
uint32_t* flagsOut
) constnoexcept[¶]

Update a path information if necessary.

BLResult BLPath::getControlBox(
BLBox* boxOut
) constnoexcept[¶]

Stores a bounding box of all vertices and control points to boxOut.

Control box is simply bounds of all vertices the path has without further processing. It contains both on-path and off-path points. Consider using getBoundingBox() if you need a visual bounding box.

BLResult BLPath::getBoundingBox(
BLBox* boxOut
) constnoexcept[¶]

Stores a bounding box of all on-path vertices and curve extrema to boxOut.

The bounding box stored to boxOut could be smaller than a bounding box obtained by getControlBox() as it's calculated by merging only start/end points and curves at their extrema (not control points). The resulting bounding box represents a visual bounds of the path.

BLResult BLPath::getFigureRange(
size_t index,
BLRange* rangeOut
) constnoexcept[¶]

Returns the range describing a figure at the given index.

BLResult BLPath::getLastVertex(
BLPoint* vtxOut
) constnoexcept[¶]

Returns the last vertex of the path and stores it to vtxOut. If the very last command of the path is BL_PATH_CMD_CLOSE then the path will be iterated in reverse order to match the initial vertex of the last figure.

BLHitTest BLPath::hitTest(
const BLPoint& p,
BLFillRule fillRule
) constnoexcept[¶]

Hit tests the given point p by respecting the given fillRule.