Skip to main content

Crate cranpose_ui_graphics

Crate cranpose_ui_graphics 

Source
Expand description

§Cranpose UI Graphics

cranpose-ui-graphics provides geometry, units, colors, brushes, paths and render-effect data. Widget authors use these values to describe visual content. Renderer authors consume the same values to produce pixels. Application code can import common types through cranpose::prelude.

§Define geometry and color

use cranpose_ui_graphics::{Color, Dp, Point, Rect, Size};

let padding = Dp(16.0);
let bounds = Rect::from_origin_size(Point::new(8.0, 12.0), Size::new(120.0, 48.0));
let accent = Color::from_rgb_u8(40, 110, 220);

The feature set is empty. Dp, Sp and Px remain distinct units; Density converts logical values to the device grid. See the Density API, the graphics API and the crate source.

Re-exports§

pub use transform::ProjectiveTransform;
pub use transform::WindowCoordinates;
pub use alpha_mask::*;
pub use liquid_glass::*;
pub use render_effect::*;
pub use unit::*;

Modules§

accessibility
Host-provided accessibility preferences shared by animation and rendering.
alpha_mask
Alpha-mask helpers for graphics-layer effects.
framework_shaders
WGSL sources for the framework’s rendering pipelines.
layer_transform
liquid_glass
LiquidGlass effect: a refractive glass material rendered via RuntimeShader.
prelude
render_effect
Render effects that can be applied to graphics layers.
transform
Projective geometry shared by layout coordinates and renderers.
unit
Length units: Dp, Sp, Px, and the Density that converts between them.

Structs§

ArcGeometry
A resolved circular band between two radii, limited to an angular sweep.
ArcRecordArgs
The arc as the app drew it, the arguments of CommandRecorder::push_arc.
BrushRecord
A gradient brush of a recording, addressed by ShapeRecord::brush.
Color
CommandRecorder
Mutable command data owned exclusively while a draw scope records it. Publishing with Self::finish shares the completed shape data without copying it.
CommandRecording
A completed draw command with shared shape data, ordered segments and non-shape primitives. Bounds and content metadata are recorded while drawing; the complete fingerprint is computed when a cache first requests it. Use CommandRecorder to build a command and Self::into_recorder to edit it.
CornerRadii
CustomPointerIcon
An application-drawn pointer shape: a bitmap plus the hotspot, the pixel inside the image that sits exactly on the pointer’s position.
DashPathEffect
Dashes along a stroke: on for the first interval, off for the second, and so on, starting phase into the pattern. Compose’s PathEffect.dashPathEffect(intervals, phase). Up to DashPathEffect::MAX_INTERVALS intervals; a pattern with an odd count or a non-positive sum draws the stroke whole, as Skia does.
DpOffset
Density-independent offset for shadows.
DrawScopeDefault
DrawTextStyle
Everything crate::DrawScope needs to measure and draw a run of text.
EdgeInsets
Padding values for each edge of a rectangle.
FontWeight
Font weight (100-900)
FxHasher
Non-cryptographic hasher for in-memory frame-to-frame change detection.
GradientStopRecord
One gradient stop in the layout the shader reads.
GraphicsLayer
ImageBitmap
Immutable image data used by UI primitives and render backends.
LineFrame
Where a pixel sits relative to a LineGeometry: its midpoint, the unit direction from start to end, and half its length.
LineGeometry
A stroked straight segment: its two ends, half its width and its cap, in the units it is drawn in. crate::DrawPrimitive::Line lowers to it, and the GPU and CPU renderers take their coverage from the same frame.
LineHeightStyle
How a line of text sits inside the height it was given, and what a paragraph gives back at its edges.
Path
A path built from lines and curves: Compose’s Path.
PathContour
One contour of a Path: its flattened points and whether it closes back to its first.
Point
RecordSegment
A run of consecutive entries of one lane that a single draw can take: shapes sharing a blend mode and a brush class, or a run of other primitives.
RecordTables
The POD half of a recording: what the GPU reads, shared with the renderer behind an Arc so a packet carries it without a copy.
RecordingSummary
What a recording contains, answered once while recording so no consumer rescans it.
Rect
RoundedCornerShape
Shadow
Static shadow configuration.
ShadowScope
Pixel-space shadow scope used by block-based APIs.
ShapeRecord
One complete recorded shape in the draw command’s local space. Every value the app passed is kept verbatim, so the record materialises back into the exact DrawPrimitive the call described, and the derived arc values the fragment stage needs sit beside them.
ShapeRecordBody
Shape properties independent of an arc’s angles, in instance-buffer layout.
ShapeRecordCurve
Corner radii and arc-angle properties, in instance-buffer layout.
ShapeRecorder
The POD half of a recording as it is written: the shape records with their brush and stop tables and coalesced segments, and the bounds those records reach. Plain data throughout, so a scene carries one across threads; CommandRecording wraps it with the other lane.
ShapeRecords
Recorded shapes stored in parallel columns, ready for GPU upload.
Size
Stroke
Describes how an outline is stroked.
TextMeasurement
What a string occupies once laid out — the answer DrawScope::measure_text gives, and exactly the box draw_text fills.
TextPrimitive
A run of text, positioned and ready to rasterize.
TransformOrigin
Trapezoid
One vertical slice of a filled path: the area between a top and a bottom edge, each straight, over the columns from left to right.
VectorPath
A parsed SVG path: subpaths flattened to polylines, ready to fill.

Enums§

BlendMode
Blend mode used for draw primitives.
Brush
ColorFilter
Simple image color filter model.
CompositingStrategy
CursorIcon
Describes the appearance of the (usually mouse) cursor icon.
DrawPrimitive
DrawStyle
How crate::DrawScope::draw_path paints a path: Compose’s Fill and Stroke draw styles, the stroke dashed when it carries a path effect.
FontStyle
Font style (normal, italic, oblique)
GradientBlurDirection
Axis and direction used to interpolate the blur radius.
ImageBitmapError
Errors returned while constructing an ImageBitmap.
ImagePixelFormat
Storage format of an immutable bitmap.
ImageSampling
Texture sampling mode for image primitives.
LayerShape
LineHeightAlignment
Where the leading — the difference between a line’s box and the font’s own ascent-plus-descent extent — is spent.
LineHeightMode
What a requested line height means when the font does not fit inside it.
LineHeightTrim
Which edges of a text block give their leading back.
PathFillRule
Fill rule for VectorPath rasterization.
PointerIcon
The pointer’s appearance over a region of the UI.
PointerIconError
Errors returned while constructing a CustomPointerIcon.
RecordLane
Which lane a segment’s entries live in.
Recorded
What ShapeRecorder::push_primitive did with a primitive.
ShadowPrimitive
StrokeCap
Shape of the two ends of an open stroked path (an arc, today).
StrokeJoin
Shape produced where two stroked segments meet at a corner.
SvgPathError
Errors produced while parsing SVG path data.
TextAlign
Horizontal placement of the text block inside the box it is drawn in.
TextVerticalAlign
Vertical placement of the text block inside the box it is drawn in.

Constants§

ARC_BAND_MIN_INNER_RADIUS
A band whose inner radius is within the strip’s margin of the centre is a disc: its strip would be the whole disc’s quad and more.
ARC_BAND_MIN_RADIUS
Bands narrower than this radius draw as their quad: the pixels a band would save cost less than its vertices.
ARC_BUCKETS
How many segment-count buckets band-drawn arcs fall into: one per power-of-two segment count of ARC_BUCKET_SEGMENTS.
ARC_BUCKET_SEGMENTS
The strip segments a bucket’s arcs are drawn with.
ARC_RING_RADII
The outer radius, in the command’s units, above which a full ring moves to the next of ARC_RING_SEGMENTS.
ARC_RING_SEGMENTS
The segments a full ring takes with an outer radius up to each of ARC_RING_RADII, and above the last: the angular step a band at that radius keeps whatever its sweep, so its chords overshoot the circle by the same few pixels and a short arc takes only the segments its sweep needs.
BAND_ANGULAR_PAD
The radians a band’s strip extends past each end of its sweep beyond the angle the ring’s padded half-width subtends at its padded inner radius, which covers every cap and the margin; float slack only. band_position pads by the same amount.
BAND_MARGIN
The device pixels a band’s quad or strip, and a line’s quad, extend past the shape on each side: the half pixel the fragment stage anti-aliases plus a sixteenth pixel for rasterization rounding. band_position in shape.wgsl pads by the same amount.
BAND_MAX_STEP
The widest angle one segment of a band’s strip spans. Past a quarter turn a strip’s outer polygon is larger than the square around the band’s padded disc, so a band whose padded sweep needs wider segments than its class has, which only a render scale below the recording’s can make, draws that square instead.
BAND_MIN_SEGMENTS
The fewest strip segments a band draws with. A short band’s strip and a rectangular shape both use four vertices in the same segment class.
BAND_VERTEX_PIXELS
What one strip vertex costs against fill, in pixels of the command’s units. A tiling GPU writes every vertex’s varyings, sixteen vectors here, to memory before it shades a pixel, and reads the record the vertex came from; a pixel reads and writes a few bytes and runs the distance field once. A band of many segments over few pixels is dearer than the quad it replaces.
BRUSH_KIND_LINEAR
The brush kinds of BrushRecord::kind.
BRUSH_KIND_RADIAL
See BRUSH_KIND_LINEAR.
BRUSH_KIND_SWEEP
See BRUSH_KIND_LINEAR.
BUILTIN_RUNTIME_SHADER_SOURCES
The framework’s own runtime shader sources. A renderer rebuilds the pipelines its last launch drew the first screen with from these, matched by crate::runtime_shader_source_hash, before the app builds them.
FRAGMENT_KIND_ARC
FRAGMENT_KIND_FILL
The fragment program’s shape kinds: a filled rect or round rect, a stroked one, an arc band, a line segment and a slice of a path fill.
FRAGMENT_KIND_LINE
FRAGMENT_KIND_STROKE
FRAGMENT_KIND_TRAPEZOID
GRADIENT_BLUR_LEVELS
The blur levels’ shares of the wide radius: the renderer blurs the capture by each, and the shader blends the sharp source and the levels around the radius each fragment asks for.
GRADIENT_BLUR_WGSL
WGSL implementation of a per-fragment Gaussian-style blur kernel.
MAX_POINTER_ICON_SIZE
The largest custom pointer icon a platform is asked to draw, in pixels.
OCCLUDER_MIN_AREA
The least interior, in square logical pixels, that a solid fill lays down ahead of the paint: a card or a background, not a chip, a glyph- sized dot or a circle, whose interior is empty.
QUAD_INDICES
The indices one quad’s two triangles take.
QUAD_VERTICES
The vertices of one quad: its four corners, which its two triangles share through the strip index pattern.
RECORD_KIND_ARC
The kind bits of ShapeRecord::flags: an arc band or annular sector.
RECORD_KIND_LINE
The kind bits of ShapeRecord::flags: a stroked straight segment, or a slice of a path fill, whose cap bits are TRAPEZOID_CAP.
RECORD_KIND_RECT
The kind bits of ShapeRecord::flags: a plain rect.
RECORD_KIND_ROUND_RECT
The kind bits of ShapeRecord::flags: a rounded rect.
TAU
Full turn in radians.
TRAPEZOID_CAP
The cap bits of a line record that is a slice of a path fill: no stroke cap takes them. Its join bits hold which of its sides are open.

Traits§

DrawScope
DrawTextMeasurer
Font-backed measurement, injected into a crate::DrawScopeDefault by the UI layer.
RenderHash

Functions§

align_text_block
Resolves the top-left corner a text block of measurement gets when it is aligned inside rect.
arc_band
Resolves the (inner, outer, cap) band described by a crate::DrawPrimitive::Arc.
arc_trig
The trig the GPU derives for a band from its normalized start and sweep: the mid-angle sine and cosine and the half-sweep sine and cosine, with the full circle’s sentinel. Arc records leave their radii zero for the GPU to fill; the renderer’s CPU mirrors of the band geometry call this.
band_bucket
The bucket of ARC_BUCKET_SEGMENTS a strip of segments draws from.
band_class_segments
The strip segments every record of band class class is drawn at.
band_padded_range
Where a band’s strip starts and the padded sweep it covers, for a band of centre-line radius mid and padded half-width ring_half over start and sweep, in one unit: the angular pad is bounded above (atan(x) is at most x), so no transcendental per band, and a sweep the pad closes is the full circle. The vertex stage takes it in device pixels, where the BAND_MARGIN the half-width includes is measured.
band_pays
Whether an arc’s band strip costs less than rect, the quad it would otherwise draw; see ShapeRecord::is_banded.
estimate_text_measurement
Font-free estimate used when no DrawTextMeasurer is installed.
expand_rect
rect grown by margin on every side.
for_each_stroke_line
Hands line the segments a stroke draws for the polyline through points, closed back to its first point when closed. An open polyline’s two ends take the stroke’s cap; every corner takes the cap closest to the stroke’s join, round for round and bevel joins, square for a miter, which is exact at a right angle. A segment whose two ends want the same cap draws with it; one whose ends differ draws butt ends, grown by half the width at a square end, and a dot of the stroke at a round one.
gradient_blur_effect
Build a spatially varying blur effect.
inflate_rect
Grows rect by amount on every side, clamping to a non-negative size.
normalized_band
The band a primitive’s arc arguments describe, normalised as the fragment stage draws it.
primitive_coverage_rect
The rect a primitive’s pixels can reach, or None when it has none of its own (a content marker or a shadow).
request_shader_warm_ups
Asks every renderer to compile the pipelines of warm_ups on its background compiler, before a frame needs them.
shader_warm_ups_after
The warm-ups requested after the first seen, in the order they were requested: a renderer passes how many it has already queued.
strip_index_pattern
The index pattern of one record’s strip of segments quads over its strip_vertices: vertex 2b sits at boundary b on the inner radius and 2b + 1 on the outer, and quad j is the triangles (2j, 2j + 1, 2j + 2) and (2j + 2, 2j + 1, 2j + 3). A quad-drawn record is the pattern’s first quad over the rect’s corners: vertex 2x + y is corner (x, y).
strip_indices
The indices a strip of segments quads draws with.
strip_vertices
The vertices a strip of segments quads shares: an inner and an outer vertex at each of its segments + 1 boundaries.

Type Aliases§

FxBuildHasher
std::hash::BuildHasher for FxHasher, for HashMap/HashSet on the per-frame path.