Geometries, paths, and transformations.
Blend2D offers various geometry structures and objects that can be used with either BLPath
for path building or BLContext
for rendering.
static
constexpr BLPoint blClamp(
const BLPoint& a,
double b,
double c)
static
constexpr BLBox operator+(
double a,
const BLBox& b)
static
constexpr BLBox operator-(
double a,
const BLBox& b)
static
constexpr BLBox operator*(
double a,
const BLBox& b)
static
constexpr BLBox operator/(
double a,
const BLBox& b)
static
constexpr BLBox operator+(
const BLBox& a,
double b)
static
constexpr BLBox operator-(
const BLBox& a,
double b)
static
constexpr BLBox operator*(
const BLBox& a,
double b)
static
constexpr BLBox operator/(
const BLBox& a,
double b)
Functions that initialize and manipulate BLMatrix2D content.
const uint8_t*
blPathGetCommandData(
const BLPathCore* self)
BLResult blPathSetVertexAt(
BLPathCore* self,
size_t index,
uint32_t cmd,
double x,
double y)
BLResult blPathCubicTo(
BLPathCore* self,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
BLResult blPathSmoothCubicTo(
BLPathCore* self,
double x2,
double y2,
double x3,
double y3)
BLResult blPathArcTo(
BLPathCore* self,
double x,
double y,
double rx,
double ry,
double start,
double sweep,
bool forceMoveTo)
BLResult blPathArcQuadrantTo(
BLPathCore* self,
double x1,
double y1,
double x2,
double y2)
BLResult blPathEllipticArcTo(
BLPathCore* self,
double rx,
double ry,
double xAxisRotation,
bool largeArcFlag,
bool sweepFlag,
double x1,
double y1)
BLResult blPathGetClosestVertex(
const BLPathCore* self,
const BLPoint* p,
double maxDistance,
size_t* indexOut,
double* distanceOut)
2D path functionality is provided by BLPathCore in C API and wrapped by BLPath in C++ API.
typedef BLResult(* BLMapPointDArrayFunc)(const void* ctx, BLPoint* dst, const BLPoint* src, size_t count)¶
A generic function that can be used to transform an array of points that use double
precision coordinates. This function will be 99.99% of time used with BLMatrix2D
so the ctx
would point to a const BLMatrix2D*
instance.
typedef BLResult(* BLPathSinkFunc)(BLPathCore* path, const void* info, void* closure)¶
Optional callback that can be used to consume a path data.
Direction of a geometry used by geometric primitives and paths.
Constant | Description |
---|
BL_GEOMETRY_DIRECTION_NONE | No direction specified.
|
BL_GEOMETRY_DIRECTION_CW | Clockwise direction.
|
BL_GEOMETRY_DIRECTION_CCW | Counter-clockwise direction.
|
Geometry type.
Geometry describes a shape or path that can be either rendered or added to a BLPath container. Both BLPath and BLContext provide functionality to work with all geometry types. Please note that each type provided here requires to pass a matching struct or class to the function that consumes a geometryType
and geometryData
arguments.
Constant | Description |
---|
BL_GEOMETRY_TYPE_NONE | No geometry provided.
|
BL_GEOMETRY_TYPE_BOXI | BLBoxI struct.
|
BL_GEOMETRY_TYPE_BOXD | BLBox struct.
|
BL_GEOMETRY_TYPE_RECTI | BLRectI struct.
|
BL_GEOMETRY_TYPE_RECTD | BLRect struct.
|
BL_GEOMETRY_TYPE_CIRCLE | BLCircle struct.
|
BL_GEOMETRY_TYPE_ELLIPSE | BLEllipse struct.
|
BL_GEOMETRY_TYPE_ROUND_RECT | BLRoundRect struct.
|
BL_GEOMETRY_TYPE_ARC | BLArc struct.
|
BL_GEOMETRY_TYPE_CHORD | BLArc struct representing chord.
|
BL_GEOMETRY_TYPE_PIE | BLArc struct representing pie.
|
BL_GEOMETRY_TYPE_LINE | BLLine struct.
|
BL_GEOMETRY_TYPE_TRIANGLE | BLTriangle struct.
|
BL_GEOMETRY_TYPE_POLYLINEI | BLArrayView<BLPointI> representing a polyline.
|
BL_GEOMETRY_TYPE_POLYLINED | BLArrayView<BLPoint> representing a polyline.
|
BL_GEOMETRY_TYPE_POLYGONI | BLArrayView<BLPointI> representing a polygon.
|
BL_GEOMETRY_TYPE_POLYGOND | BLArrayView<BLPoint> representing a polygon.
|
BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXI | BLArrayView<BLBoxI> struct.
|
BL_GEOMETRY_TYPE_ARRAY_VIEW_BOXD | BLArrayView<BLBox> struct.
|
BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTI | BLArrayView<BLRectI> struct.
|
BL_GEOMETRY_TYPE_ARRAY_VIEW_RECTD | BLArrayView<BLRect> struct.
|
BL_GEOMETRY_TYPE_PATH | BLPath (or BLPathCore).
|
BL_GEOMETRY_TYPE_MAX_VALUE | Maximum value of BLGeometryType .
|
Fill rule.
Constant | Description |
---|
BL_FILL_RULE_NON_ZERO | Non-zero fill-rule.
|
BL_FILL_RULE_EVEN_ODD | Even-odd fill-rule.
|
BL_FILL_RULE_MAX_VALUE | Maximum value of BLFillRule .
|
Hit-test result.
Constant | Description |
---|
BL_HIT_TEST_IN | Fully in.
Partially in/out.
|
BL_HIT_TEST_PART | Fully out.
|
BL_HIT_TEST_OUT | Hit test failed (invalid argument, NaNs, etc).
|
2D matrix type that can be obtained by calling BLMatrix2D::type()
.
Identity Transl. Scale Swap Affine
[1 0] [1 0] [. 0] [0 .] [. .]
[0 1] [0 1] [0 .] [. 0] [. .]
[0 0] [. .] [. .] [. .] [. .]
Constant | Description |
---|
BL_MATRIX2D_TYPE_IDENTITY | Identity matrix.
|
BL_MATRIX2D_TYPE_TRANSLATE | Has translation part (the rest is like identity).
|
BL_MATRIX2D_TYPE_SCALE | Has translation and scaling parts.
|
BL_MATRIX2D_TYPE_SWAP | Has translation and scaling parts, however scaling swaps X/Y.
|
BL_MATRIX2D_TYPE_AFFINE | Generic affine matrix.
|
BL_MATRIX2D_TYPE_INVALID | Invalid/degenerate matrix not useful for transformations.
|
BL_MATRIX2D_TYPE_MAX_VALUE | Maximum value of BLMatrix2DType .
|
2D matrix data index.
Constant | Description |
---|
BL_MATRIX2D_VALUE_00 | Value at index 0 - M00.
|
BL_MATRIX2D_VALUE_01 | Value at index 1 - M01.
|
BL_MATRIX2D_VALUE_10 | Value at index 2 - M10.
|
BL_MATRIX2D_VALUE_11 | Value at index 3 - M11.
|
BL_MATRIX2D_VALUE_20 | Value at index 4 - M20.
|
BL_MATRIX2D_VALUE_21 | Value at index 5 - M21.
|
BL_MATRIX2D_VALUE_MAX_VALUE | Count of BLMatrix2D values.
|
2D matrix operation.
Constant | Description |
---|
BL_MATRIX2D_OP_RESET | Reset matrix to identity (argument ignored, should be nullptr).
|
BL_MATRIX2D_OP_ASSIGN | Assign (copy) the other matrix.
|
BL_MATRIX2D_OP_TRANSLATE | Translate the matrix by [x, y].
|
BL_MATRIX2D_OP_SCALE | Scale the matrix by [x, y].
|
BL_MATRIX2D_OP_SKEW | Skew the matrix by [x, y].
|
BL_MATRIX2D_OP_ROTATE | Rotate the matrix by the given angle about [0, 0].
|
BL_MATRIX2D_OP_ROTATE_PT | Rotate the matrix by the given angle about [x, y].
|
BL_MATRIX2D_OP_TRANSFORM | Transform this matrix by other BLMatrix2D .
|
BL_MATRIX2D_OP_POST_TRANSLATE | Post-translate the matrix by [x, y].
|
BL_MATRIX2D_OP_POST_SCALE | Post-scale the matrix by [x, y].
|
BL_MATRIX2D_OP_POST_SKEW | Post-skew the matrix by [x, y].
|
BL_MATRIX2D_OP_POST_ROTATE | Post-rotate the matrix about [0, 0].
|
BL_MATRIX2D_OP_POST_ROTATE_PT | Post-rotate the matrix about a reference BLPoint.
|
BL_MATRIX2D_OP_POST_TRANSFORM | Post-transform this matrix by other BLMatrix2D .
|
BL_MATRIX2D_OP_MAX_VALUE | Maximum value of BLMatrix2DOp .
|
Path command.
Constant | Description |
---|
BL_PATH_CMD_MOVE | Move-to command (starts a new figure).
|
BL_PATH_CMD_ON | On-path command (interpreted as line-to or the end of a curve).
|
BL_PATH_CMD_QUAD | Quad-to control point.
|
BL_PATH_CMD_CUBIC | Cubic-to control point (always used as a pair of commands).
|
BL_PATH_CMD_CLOSE | Close path.
|
BL_PATH_CMD_MAX_VALUE | Maximum value of BLPathCmd .
|
Path command (never stored in path).
Constant | Description |
---|
BL_PATH_CMD_PRESERVE | Used by BLPath::setVertexAt to preserve the current command value.
|
Path flags.
Constant | Description |
---|
BL_PATH_NO_FLAGS | No flags.
|
BL_PATH_FLAG_EMPTY | Path is empty (no commands or close commands only).
|
BL_PATH_FLAG_MULTIPLE | Path contains multiple figures.
|
BL_PATH_FLAG_QUADS | Path contains one or more quad curves.
|
BL_PATH_FLAG_CUBICS | Path contains one or more cubic curves.
|
BL_PATH_FLAG_INVALID | Path is invalid.
|
BL_PATH_FLAG_DIRTY | Flags are dirty (not reflecting the current status).
|
Path reversal mode.
Constant | Description |
---|
BL_PATH_REVERSE_MODE_COMPLETE | Reverse each figure and their order as well (default).
|
BL_PATH_REVERSE_MODE_SEPARATE | Reverse each figure separately (keeps their order).
|
BL_PATH_REVERSE_MODE_MAX_VALUE | Maximum value of BLPathReverseMode .
|
Stroke join type.
Constant | Description |
---|
BL_STROKE_JOIN_MITER_CLIP | Miter-join possibly clipped at miterLimit [default].
|
BL_STROKE_JOIN_MITER_BEVEL | Miter-join or bevel-join depending on miterLimit condition.
|
BL_STROKE_JOIN_MITER_ROUND | Miter-join or round-join depending on miterLimit condition.
|
BL_STROKE_JOIN_BEVEL | Bevel-join.
|
BL_STROKE_JOIN_ROUND | Round-join.
|
BL_STROKE_JOIN_MAX_VALUE | Maximum value of BLStrokeJoin .
|
Position of a stroke-cap.
Constant | Description |
---|
BL_STROKE_CAP_POSITION_START | Start of the path.
|
BL_STROKE_CAP_POSITION_END | End of the path.
|
BL_STROKE_CAP_POSITION_MAX_VALUE | Maximum value of BLStrokeCapPosition .
|
A presentation attribute defining the shape to be used at the end of open subpaths.
Constant | Description |
---|
BL_STROKE_CAP_BUTT | Butt cap [default].
|
BL_STROKE_CAP_SQUARE | Square cap.
|
BL_STROKE_CAP_ROUND | Round cap.
|
BL_STROKE_CAP_ROUND_REV | Round cap reversed.
|
BL_STROKE_CAP_TRIANGLE | Triangle cap.
|
BL_STROKE_CAP_TRIANGLE_REV | Triangle cap reversed.
|
BL_STROKE_CAP_MAX_VALUE | Maximum value of BLStrokeCap .
|
Stroke transform order.
Constant | Description |
---|
BL_STROKE_TRANSFORM_ORDER_AFTER | Transform after stroke => Transform(Stroke(Input)) [default].
|
BL_STROKE_TRANSFORM_ORDER_BEFORE | Transform before stroke => Stroke(Transform(Input)) .
|
BL_STROKE_TRANSFORM_ORDER_MAX_VALUE | Maximum value of BLStrokeTransformOrder .
|
Mode that specifies how curves are approximated to line segments.
Constant | Description |
---|
BL_FLATTEN_MODE_DEFAULT | Use default mode (decided by Blend2D).
|
BL_FLATTEN_MODE_RECURSIVE | Recursive subdivision flattening.
|
BL_FLATTEN_MODE_MAX_VALUE | Maximum value of BLFlattenMode .
|
Mode that specifies how to construct offset curves.
Constant | Description |
---|
BL_OFFSET_MODE_DEFAULT | Use default mode (decided by Blend2D).
|
BL_OFFSET_MODE_ITERATIVE | Iterative offset construction.
|
BL_OFFSET_MODE_MAX_VALUE | Maximum value of BLOffsetMode .
|
Array of functions for transforming points indexed by BLMatrixType
. Each function is optimized for the respective type. This is mostly used internally, but exported for users that can take advantage of Blend2D SIMD optimziations.
Default approximation options used by Blend2D.