cf_draw_shape_group_begin¶
Category: draw
GitHub: cute_draw.h
Begins a shape group: subsequent SDF shape calls compose with boolean ops into ONE shape.
Remarks¶
Between begin and cf_draw_shape_group_end (or cf_draw_shape_group_end_stroked), calls like cf_draw_circle_fill, cf_draw_quad_fill, cf_draw_tri_fill, cf_draw_polygon_fill, cf_draw_capsule_fill, cf_draw_line, cf_draw_arrow, and cf_draw_custom_shape_fill record operands instead of drawing. The first operand is the base; each following operand folds in with the op set by cf_draw_shape_group_op (union by default). The composite renders as a single command with a single distance field, which means: translucent composites blend exactly once (no double-blend at overlaps), and the whole composite can be outlined via cf_draw_shape_group_end_stroked -- impossible with stacked separate draws.
A crescent moon in three lines:
cf_draw_shape_group_begin();
cf_draw_circle_fill2(cf_v2(0, 0), 70);
cf_draw_shape_group_op(CF_SHAPE_OP_SUBTRACT, 0);
cf_draw_circle_fill2(cf_v2(-32, 18), 62);
cf_draw_shape_group_end();
Colors and per-operand strokes of the operand calls are ignored -- the composite takes the draw state (color, antialias, layer) at end() time. Sprites, text, and polylines do not join groups (they have no single distance function) and draw normally. Do not change the camera between begin and end. Bounds are computed automatically from the operands.
Related Pages¶
CF_ShapeOp
cf_draw_shape_group_op
cf_draw_shape_group_end
cf_draw_shape_group_end_stroked