bezier_circuit

Cubic bezier circuits – the geometry behind every 2-D shape.

BezierCircuitCubic is a closed loop of cubic bezier curves, stored as control points. It is what Circle, Square, Text and Tex are made of, which is why a circle is a true circle at any zoom rather than a many-sided polygon, and why any of them can morph into any other.

The class owns the fill/border model as well as the geometry: on a filled shape the border is drawn inside the outline, so raising stroke_width eats into the fill instead of growing the silhouette – which keeps bordered text legible and stops neighbouring glyphs fusing. An unfilled circuit has no interior to eat into, so its stroke stays centred on the path.

It owns color across the shape too, through a grid_width x grid_height grid of colored points laid over the circuit’s own frame, which the renderer samples bilinearly per fragment. This is the same thing Surface calls its grid, over the same (u, v) domain, and it is named to match: a circuit is always planar, so there is no reason to give it separate vertex colors and a texture map the way a curved surface needs – one grid is both. BezierCircuitCubic.set_color_by_function() fills it in from (u, v), BezierCircuitCubic.set_color_by_image() from a picture, and set_color_by_function() from a single t along the path. The grid is one point, i.e. one flat color, unless it was asked for.

build_render_primitives_batched packs many circuits into one BezierCircuitPrimitive for the renderer, which evaluates the curves analytically rather than tessellating them.

Classes

BezierCircuitCubic

A closed loop of cubic bezier curves -- the geometry every 2-D shape is made of.

BezierCurveCubic

An open path of cubic bezier curves -- a stroke with no interior.

Functions

build_render_primitives_batched(actors, scene)[source]

Build the merged (collection-level) bezier render primitive for actors in one vectorized pass.

Byte-identical replacement for calling get_render_primitives() on every actor and concatenating the per-actor primitives through BezierCircuitPrimitive(triangle_collection=...): each attribute is read from its timeline once for the whole group (contiguous rows read as a single slice), and the per-segment circuit topology (subpath start/end masks, next-segment indices) is computed with per-actor index maps that reproduce each actor’s local roll/cummax wrap-around semantics.

Callers must guarantee (see RenderLoopMixin._is_batchable_bezier and _build_deferred_beziers): stock BezierCircuitCubic build methods, not empty, un-batched control points, singleton rows for the scalar attributes, and uniform num_texture_points / filled / fill and border texture-color row counts / primitive class across the group.