BLPath Class Reference

2D vector path [C++ API].

Member Functions

Construction & Destruction
Overloaded Operators
Common Functionality
Path Content
Path Construction
Adding Figures
Adding Paths
Manipulation
Transformations
Path Information
Hit Testing

Static Functions

Additional Inherited Members

- Public Attributes inherited from BLPathCore

Member Function Documentation

bool BLPath::isNone() const

Tests whether the 2D path is a built-in null instance.

bool BLPath::empty() const

Tests whether the path is empty (its size equals zero).

bool BLPath::equals(const BLPath& other) const

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

size_t BLPath::size() const

Returns path size (count of vertices used).

size_t BLPath::capacity() const

Returns path capacity (count of allocated vertices).

const BLPoint* BLPath::vertexData() const

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

const BLPoint* BLPath::vertexDataEnd() const

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

const uint8_t* BLPath::commandData() const

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

const uint8_t* BLPath::commandDataEnd() const

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

const BLPathView& BLPath::view() const

Returns the path data as a read-only BLPathView.

BLResult BLPath::clear()

Clears the content of the path.

BLResult BLPath::shrink()

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

BLResult BLPath::reserve(size_t n)

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)[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)[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)[1/2]

Moves to p0.

Appends BL_PATH_CMD_MOVE[p0] command to the path.

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

Moves to [x0, y0].

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

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

Adds line to p1.

Appends BL_PATH_CMD_ON[p1] command to the path.

BLResult BLPath::lineTo(double x1, double y1)[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)

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

Closes the current figure.

Appends BL_PATH_CMD_CLOSE to the path.

Matches SVG 'Z' path command:

BLResult BLPath::addBox(const BLBoxI& box, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/3]

Adds a closed rectangle to the path specified by box.

BLResult BLPath::addBox(const BLBox& box, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[2/3]

Adds a closed rectangle to the path specified by box.

BLResult BLPath::addBox(double x0, double y0, double x1, double y1, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[3/3]

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

BLResult BLPath::addRect(const BLRectI& rect, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/3]

Adds a closed rectangle to the path specified by rect.

BLResult BLPath::addRect(const BLRect& rect, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[2/3]

Adds a closed rectangle to the path specified by rect.

BLResult BLPath::addRect(double x, double y, double w, double h, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[3/3]

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

BLResult BLPath::addGeometry(uint32_t geometryType, const void* geometryData, const BLMatrix2D* m = nullptr, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)

Adds a geometry to the path.

BLResult BLPath::addCircle(const BLCircle& circle, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed circle to the path.

BLResult BLPath::addCircle(const BLCircle& circle, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed ellipse to the path.

BLResult BLPath::addEllipse(const BLEllipse& ellipse, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed rounded ractangle to the path.

BLResult BLPath::addRoundRect(const BLRoundRect& rr, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds an unclosed arc to the path.

BLResult BLPath::addArc(const BLArc& arc, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed chord to the path.

BLResult BLPath::addChord(const BLArc& chord, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed pie to the path.

BLResult BLPath::addPie(const BLArc& pie, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds an unclosed line to the path.

BLResult BLPath::addLine(const BLLine& line, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed triangle.

BLResult BLPath::addTriangle(const BLTriangle& triangle, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/8]

Adds a polyline.

BLResult BLPath::addPolyline(const BLArrayView<BLPointI>& poly, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[5/8]

Adds a polyline.

BLResult BLPath::addPolyline(const BLArrayView<BLPoint>& poly, const BLMatrix2D& m, uint32_t dir)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/8]

Adds a polygon.

BLResult BLPath::addPolygon(const BLArrayView<BLPointI>& poly, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[5/8]

Adds a polygon.

BLResult BLPath::addPolygon(const BLArrayView<BLPoint>& poly, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/8]

Adds an array of closed boxes.

BLResult BLPath::addBoxArray(const BLArrayView<BLBoxI>& array, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[5/8]

Adds an array of closed boxes.

BLResult BLPath::addBoxArray(const BLArrayView<BLBox>& array, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/8]

Adds an array of closed rectangles.

BLResult BLPath::addRectArray(const BLArrayView<BLRectI>& array, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[5/8]

Adds an array of closed rectangles.

BLResult BLPath::addRectArray(const BLArrayView<BLRect>& array, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[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::addRegion(const BLRegion& region, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[1/2]

Adds a closed region (converted to set of rectangles).

BLResult BLPath::addRegion(const BLRegion& region, const BLMatrix2D& m, uint32_t dir = BL_GEOMETRY_DIRECTION_CW)[2/2]

Adds a closed region (converted to set of rectangles).

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

Adds other path to this path.

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

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

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

Adds other path translated by p to this path.

BLResult BLPath::addPath(const BLPath& path, const BLRange& range, const BLPoint& p)[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& m)[5/6]

Adds other path transformed by m to this path.

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

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

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

Adds other path, but reversed.

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

Adds other path, but reversed.

BLResult BLPath::addStrokedPath(const BLPath& path, const BLRange& range, const BLStrokeOptions& strokeOptions, const BLApproximationOptions& approximationOptions)[1/2]

Adds a stroke of path to this path.

BLResult BLPath::addStrokedPath(const BLPath& path, const BLStrokeOptions& strokeOptions, const BLApproximationOptions& approximationOptions)[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)[1/2]

Translates the whole path by p.

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

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

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

Transforms the whole path by matrix m.

BLResult BLPath::transform(const BLRange& range, const BLMatrix2D& m)[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)[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)[2/2]

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

BLResult BLPath::getInfoFlags(uint32_t* flagsOut) const

Update a path information if necessary.

BLResult BLPath::getControlBox(BLBox* boxOut) const

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

Stores a bounding box of all on-path vertices and curve extremas 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 extremas (not control points). The resulting bounding box represents a visual bounds of the path.

BLResult BLPath::getFigureRange(size_t index, BLRange* rangeOut) const

Returns the range describing a figure at the given index.

BLResult BLPath::getLastVertex(BLPoint* vtxOut)

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.

uint32_t BLPath::hitTest(const BLPoint& p, uint32_t fillRule) const

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