Geometry API

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.

Classes

Enumerations

BLMatrix Constants

BLPath - Constants

BLPath - C API

BLPath - Globals

2D path functionality is provided by BLPathCore in C API and wrapped by BLPath in C++ API.

Global Specializations

Overloaded Operators

BLMatrix2D - C API

Functions that initialize and manipulate BLMatrix2D content.

Typedef Documentation

typedef BLResult(* BLPathSinkFunc)(BLPathCore* path, const void* info, void* userData)◆ 

Optional callback that can be used to consume a path data.

typedef BLResult(* BLPathStrokeSinkFunc)(BLPathCore* a, BLPathCore* b, BLPathCore* c, size_t inputStart, size_t inputEnd, void* userData)◆ 

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

Enumeration Type Documentation

BLGeometryDirection : uint32_tenum◆ 

Direction of a geometry used by geometric primitives and paths.

ConstantDescription
BL_GEOMETRY_DIRECTION_NONE 

No direction specified.

BL_GEOMETRY_DIRECTION_CW 

Clockwise direction.

BL_GEOMETRY_DIRECTION_CCW 

Counter-clockwise direction.

BLGeometryType : uint32_tenum◆ 

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.

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

BLFillRule : uint32_tenum◆ 

Fill rule.

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

BLHitTest : uint32_tenum◆ 

Hit-test result.

ConstantDescription
BL_HIT_TEST_IN 

Fully in.

BL_HIT_TEST_PART 

Partially in/out.

BL_HIT_TEST_OUT 

Fully out.

BL_HIT_TEST_INVALID 

Hit test failed (invalid argument, NaNs, etc).

BLTransformType : uint32_tenum◆ 

Transformation 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] [. .] [. .] [. .] [. .]
ConstantDescription
BL_TRANSFORM_TYPE_IDENTITY 

Identity matrix.

BL_TRANSFORM_TYPE_TRANSLATE 

Has translation part (the rest is like identity).

BL_TRANSFORM_TYPE_SCALE 

Has translation and scaling parts.

BL_TRANSFORM_TYPE_SWAP 

Has translation and scaling parts, however scaling swaps X/Y.

BL_TRANSFORM_TYPE_AFFINE 

Generic affine matrix.

BL_TRANSFORM_TYPE_INVALID 

Invalid/degenerate matrix not useful for transformations.

BL_TRANSFORM_TYPE_MAX_VALUE 

Maximum value of BLTransformType.

BLTransformOp : uint32_tenum◆ 

Transformation matrix operation type.

ConstantDescription
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 BLTransformOp.

BLPathCmd : uint32_tenum◆ 

Path command.

ConstantDescription
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_CONIC 

Conic-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_WEIGHT 

Conic weight.

Note
This is not a point. This is a pair of values from which only the first (x) is used to represent weight as used by conic curve. The other value (y) is always set to NaN by Blend2D, but can be arbitrary as it has no meaning.
BL_PATH_CMD_MAX_VALUE 

Maximum value of BLPathCmd.

BLPathCmdExtra : uint32_tenum◆ 

Path command (never stored in path).

ConstantDescription
BL_PATH_CMD_PRESERVE 

Used by BLPath::setVertexAt to preserve the current command value.

BLPathFlags : uint32_tenum◆ 

Path flags.

ConstantDescription
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_CONICS 

Path contains one or more conic 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).

BLPathReverseMode : uint32_tenum◆ 

Path reversal mode.

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

BLStrokeJoin : uint32_tenum◆ 

Stroke join type.

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

BLStrokeCapPosition : uint32_tenum◆ 

Position of a stroke-cap.

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

BLStrokeCap : uint32_tenum◆ 

A presentation attribute defining the shape to be used at the end of open sub-paths.

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

BLStrokeTransformOrder : uint32_tenum◆ 

Stroke transform order.

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

BLFlattenMode : uint32_tenum◆ 

Mode that specifies how curves are approximated to line segments.

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

BLOffsetMode : uint32_tenum◆ 

Mode that specifies how to construct offset curves.

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

Variable Documentation

const BLApproximationOptions blDefaultApproximationOptionsextern◆ 

Default approximation options used by Blend2D.