Expand description
Pure math/data for drawing & units in Cranpose
This crate contains geometry primitives, color definitions, brushes, and unit types that are used throughout the Cranpose framework.
Re-exports§
pub use alpha_mask::*;pub use liquid_glass::*;pub use render_effect::*;pub use unit::*;
Modules§
- alpha_
mask - Alpha-mask helpers for graphics-layer effects.
- framework_
shaders - WGSL sources for the framework’s rendering pipelines.
- liquid_
glass - LiquidGlass effect: a refractive glass material rendered via RuntimeShader.
- prelude
- render_
effect - Render effects that can be applied to graphics layers.
- unit
- Length units:
Dp,Sp,Px, and theDensitythat converts between them.
Structs§
- ArcGeometry
- A resolved circular band between two radii, limited to an angular sweep.
- Color
- Command
Recording - One draw command’s recording in compact typed form: pure-numeric records
for the common solid shapes (no
Brushdestructor branch, roughly half the bytes of theDrawPrimitivethey materialize into) and ordinary primitives for everything else, withtapepreserving global order. The index each tape entry carries into its per-kind store is the stable compact handle for the rare resource-bearing entries (othersholds gradients, images, text, blends, and content markers whole). - Command
Replay Frame - A command’s replay verdict translated into the space its consumers see: spans address the run’s materialized primitive vector, not the record tape. This is what rides the render graph next to the primitives.
- Command
Replay State - Per-command replay state: the retained snapshot (previous stable form of the recording) and the segments carved out of it. This is the double buffer sol’s plan sanctions — previous and current forms coexist only for comparison.
- Command
Segment - One retained stretch of a command’s recording, addressed by the retained
snapshot’s tape range. The
idis stable for the segment’s lifetime — renderer-side retained slots key on it, and it survives other segments dying. - Corner
Radii - DpOffset
- Density-independent offset for shadows.
- Draw
Scope Default - Draw
Text Style - Everything
crate::DrawScopeneeds to measure and draw a run of text. - Edge
Insets - Padding values for each edge of a rectangle.
- Finished
Recording - What
DrawScopeDefault::finishhands back: the materialized primitives, the marker count that travels with them, and the recording buffers so a retaining caller can lend them to the same command’s next recording. - Font
Weight - Font weight (100-900)
- FxHasher
- Non-cryptographic hasher for in-memory frame-to-frame change detection.
- Graphics
Layer - Image
Bitmap - Immutable RGBA image data used by UI primitives and render backends.
- Line
Height Style - How a line of text sits inside the height it was given.
- Point
- Record
Transform - One segment’s frame-over-frame motion: uniform scale and rotation about a shared external center.
- Rect
- Rounded
Corner Shape - Shadow
- Static shadow configuration.
- Shadow
Scope - Pixel-space shadow scope used by block-based APIs.
- Size
- Solid
ArcRecord - A solid
SrcOverarc, recorded as the RAW draw parameters — before band resolution, tight-bounds trigonometry, or the degeneracy check, all of which happen at materialization. Retention verification must be able to compare what the app said, ahead of everything deriving from it. - Solid
Rect Record - A solid
SrcOverrect, recorded as raw values. - Solid
Round Rect Record - A solid
SrcOverrounded rect (also the lowering ofdraw_circle), recorded as raw values. - Stroke
- Describes how an outline is stroked.
- Text
Measurement - What a string occupies once laid out — the answer
DrawScope::measure_textgives, and exactly the boxdraw_textfills. - Text
Primitive - A run of text, positioned and ready to rasterize.
- Transform
Origin - Vector
Path - A parsed SVG path: subpaths flattened to polylines, ready to fill.
Enums§
- Blend
Mode - Blend mode used for draw primitives.
- Brush
- Color
Filter - Simple image color filter model.
- Compositing
Strategy - Controls how a graphics layer is composited into its parent target.
- Draw
Primitive - Font
Style - Font style (normal, italic, oblique)
- Frame
Span - One primitive-space span of a
CommandReplayFrame. - Gradient
Blur Direction - Axis and direction used to interpolate the blur radius.
- Image
Bitmap Error - Errors returned while constructing an
ImageBitmap. - Image
Sampling - Texture sampling mode for image primitives.
- Layer
Shape - Line
Height Alignment - Where the leading — the difference between a line’s box and the font’s own ascent-plus-descent extent — is spent.
- Line
Height Mode - What a requested line height means when the font does not fit inside it.
- Line
Height Trim - Which edges of a text block give their leading back.
- Path
Fill Rule - Fill rule for
VectorPathrasterization. - Record
Match - The result of verifying one incoming record against its retained counterpart under a segment transform.
- Replay
Outcome - What one frame of verification decided for a command.
- Replay
Span - One span of this frame’s recording, in tape order.
- Shadow
Primitive - Describes a shadow to be rendered. Each renderer chooses how to blur.
- Stroke
Cap - Shape of the two ends of an open stroked path (an arc, today).
- Stroke
Join - Shape produced where two stroked segments meet at a corner.
- SvgPath
Error - Errors produced while parsing SVG path data.
- Text
Align - Horizontal placement of the text block inside the box it is drawn in.
- Text
Vertical Align - Vertical placement of the text block inside the box it is drawn in.
Constants§
- GRADIENT_
BLUR_ WGSL - WGSL implementation of a per-fragment Gaussian-style blur kernel.
- MAX_
SEGMENT_ RECORDS - Chains longer than this split into multiple groups, bounding the blast radius of any one entry going dynamic later.
- MIN_
REPLAY_ COMMAND_ RECORDS - Below this many records a command is not worth watching at all.
- MIN_
SEGMENT_ RECORDS - Below this many entries a stable stretch is not worth a retained group. Mirrors the flat-list detector.
- TAU
- Full turn in radians.
Traits§
- Draw
Scope - Draw
Text Measurer - Font-backed measurement, injected into a
crate::DrawScopeDefaultby the UI layer. - Render
Hash - Verify
Executor - Fans independent verification bodies across worker threads.
run(i)is called exactly once for everyi in 0..jobs, from any thread; the call returns only after every job finished (jobs borrow the caller’s stack). The renderer wires its frame worker pool in through this seam so the recorder crate stays free of threading machinery.
Functions§
- align_
text_ block - Resolves the top-left corner a text block of
measurementgets when it is aligned insiderect. - arc_
anchor_ transform - Derives the segment transform from an arc anchor pair. Arcs pin both scale and rotation exactly.
- arc_
band - Resolves the
(inner, outer, cap)band described by acrate::DrawPrimitive::Arc. - arcs_
anchor_ compatible - Similarity-invariant compatibility of a fresh arc with a retained one, for re-locating a segment when dynamic spans change length. Colors are deliberately excluded — a twinkling anchor must still re-anchor its segment. A false positive costs a failed probe, never a wrong pixel.
- circle_
anchor_ transform_ pinned - Derives the segment transform from a circle anchor pair, with its pinnedness (an on-pivot circle pins no rotation).
- circle_
view - A circular round-rect (corner radius == half extent on every corner):
the one rect family that stays itself under rotation about an external
pivot. Returns
(center, diameter). - estimate_
text_ measurement - Font-free estimate used when no
DrawTextMeasureris installed. - gradient_
blur_ effect - Build a spatially varying blur effect.
- inflate_
rect - Grows
rectbyamounton every side, clamping to a non-negative size. - is_
circle - Whether corner radii + extents describe a circle.
- match_
arc - Verifies a fresh arc record against the retained one under
t. Arc centers must sit on the shared pivot — that is what makes rotation a value change instead of a position change. - match_
round_ rect - Verifies a fresh circular round-rect against the retained one under
t. Non-circular round rects never match — they do not survive rotation about an external pivot. - transforms_
group - Whether an entry’s own implied transform is tightly consistent with a
chain’s anchor transform.
pinnedmarks transforms whose angle is meaningful — an on-pivot circle pins no rotation and joins any chain.
Type Aliases§
- FxBuild
Hasher std::hash::BuildHasherforFxHasher, forHashMap/HashSeton the per-frame path.