Blend2D
2D Vector Graphics Engine
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. In general there are two categories - BLPath, which specifies a 2D path composed of path segments, and lightweight geometries such as BLRect, BLRoundRect, etc... which are only described by a trivial C/C++ struct.
[x, y]
values (64-bit floats)[x, y]
values (32-bit integers)[w, h]
values (64-bit floats)[w, h]
values (32-bit integers)[x0, y0, x1, y1]
values (64-bit floats)[x0, y0, x1, y1]
values (32-bit integers)[x, y, w, h]
values (64-bit floats)[x, y, w, h]
values (32-bit integers)[x, y, w, h]
with radius [rx, ry]
(64-bit floats)[cx, cy]
with radius r
(64-bit floats)[cx, cy]
with radius [rx, ry]
(64-bit floats)[cx, cy]
with radius [rx, ry]
and start
+ sweep
values (64-bit floats)[x0, y0]
to [x1, y1]
(64-bit floats)[x0, y0]
, [x1, y1]
, and [x2, y2]
vertices (64-bit floats)2D path functionality is provided by BLPathCore in C API and wrapped by BLPath in C++ API.
Optional callback that can be used to consume a path data.
This is a sink that is used by path offsetting. This sink consumes both a
and b
offsets of the path. The sink will be called for each figure and is responsible for joining these paths. If the paths are not closed then the sink must insert start cap, then join b
, and then insert end cap.
The sink must also clean up the paths as this is not done by the offsetter. The reason is that in case the a
path is the output path you can just keep it and insert b
path into it (clearing only b
path after each call).
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 |
Transformation matrix type that can be obtained by calling BLMatrix2D::type()
.
Transformation matrix operation type.
Constant | Description |
---|---|
BL_TRANSFORM_OP_RESET | Reset matrix to identity (argument ignored, should be nullptr). |
BL_TRANSFORM_OP_ASSIGN | Assign (copy) the other matrix. |
BL_TRANSFORM_OP_TRANSLATE | Translate the matrix by [x, y]. |
BL_TRANSFORM_OP_SCALE | Scale the matrix by [x, y]. |
BL_TRANSFORM_OP_SKEW | Skew the matrix by [x, y]. |
BL_TRANSFORM_OP_ROTATE | Rotate the matrix by the given angle about [0, 0]. |
BL_TRANSFORM_OP_ROTATE_PT | Rotate the matrix by the given angle about [x, y]. |
BL_TRANSFORM_OP_TRANSFORM | Transform this matrix by other BLMatrix2D. |
BL_TRANSFORM_OP_POST_TRANSLATE | Post-translate the matrix by [x, y]. |
BL_TRANSFORM_OP_POST_SCALE | Post-scale the matrix by [x, y]. |
BL_TRANSFORM_OP_POST_SKEW | Post-skew the matrix by [x, y]. |
BL_TRANSFORM_OP_POST_ROTATE | Post-rotate the matrix about [0, 0]. |
BL_TRANSFORM_OP_POST_ROTATE_PT | Post-rotate the matrix about a reference BLPoint. |
BL_TRANSFORM_OP_POST_TRANSFORM | Post-transform this matrix by other BLMatrix2D. |
BL_TRANSFORM_OP_MAX_VALUE | Maximum value of |
Path command.
Path command (never stored in path).
Constant | Description |
---|---|
BL_PATH_CMD_PRESERVE | Used by |
Path flags.
Stroke join type.
A presentation attribute defining the shape to be used at the end of open sub-paths.
Default approximation options used by Blend2D.