Skip to main content

Crate frus_core

Crate frus_core 

Source
Expand description

frus-core — the fundamental types shared by the whole framework.

This crate holds no logic: only data types (geometry, colour) with no dependency on rendering or on any platform. It is the common foundation for frus-gpu, frus-layout and the rest, which keeps those layers from duplicating types or coupling to one another.

Re-exports§

pub use animation::Animatable;
pub use animation::Animation;
pub use animation::AnimationController;
pub use animation::BouncingScrollSimulation;
pub use animation::ClampedSimulation;
pub use animation::ClampingScrollSimulation;
pub use animation::Curve;
pub use animation::Curved;
pub use animation::FrictionSimulation;
pub use animation::Lerp;
pub use animation::PolynomialFit;
pub use animation::Simulation;
pub use animation::SpringDescription;
pub use animation::SpringSimulation;
pub use animation::Status;
pub use animation::Tolerance;
pub use animation::Tween;
pub use animation::TweenSequence;
pub use animation::Velocity;
pub use animation::VelocityEstimate;
pub use animation::VelocityStrategy;
pub use animation::VelocityTracker;
pub use animation::BOUNCING_DRAG;
pub use animation::BOUNCING_FLING_WEIGHTS;
pub use animation::CLAMPING_FRICTION;
pub use animation::DESKTOP_FLING_WEIGHTS;
pub use animation::MAX_SPRING_TRANSFER_VELOCITY;

Modules§

animation
Animation: the physics and kinematics layer shared by the whole framework, with no dependency on rendering or on any platform.

Structs§

Affine
A 2D affine transform (a 2×3 matrix). A point (x, y) becomes (a·x + c·y + e, b·x + d·y + f): a 2×2 linear part [[a, c], [b, d]] (scale, rotation, shear) plus a translation (e, f).
Alignment
Where to place a child inside its containing box: two continuous fractions in [-1, 1]. x = -1 hugs the left, 0 centres, +1 hugs the right; y = -1 is the top, +1 the bottom. Being continuous, it interpolates (crate::Lerp): a Tween<Alignment> slides a child from one anchor to another. The nine usual anchors are provided as constants (Alignment::CENTER, Alignment::TOP_LEFT, and so on).
AlignmentDirectional
A directional anchor: the horizontal axis is expressed start → end rather than left → right. x_start = -1 hugs the start edge (left in LTR, right in RTL), +1 the end edge. Resolved into a physical Alignment at render time from the reading direction — the anchor follows the text without the caller ever testing which way it runs.
Backdrop
A filter over what has already been painted underneath a layer: the frosted glass a sheet, a bar or a dialog sits on.
Border
A uniform border — the same width and colour on all four sides.
BorderRadius
Corner radii, per corner (logical px). From<f32> covers the uniform case: anywhere a radius is expected, a plain 10.0 still works.
BorderRadiusDirectional
A corner radius named by the reading direction rather than by the wall (border_radius.dart:621).
BorderSide
One edge of a shape: what colour it is drawn in and how thick it is (border_side.dart).
BoxDecoration
The complete decoration of a rectangular box.
BoxShadow
A soft drop shadow.
Color
An RGBA colour. Components lie in [0.0, 1.0].
Colors
The named colours of the material palette, as plain Color constants.
Hct
A colour in HCT: CAM16 hue (degrees), CAM16 chroma, and L* tone.
ImageData
An image’s pixels: 8-bit RGBA, sRGB, row by row from the top-left corner (width * height * 4 bytes). Immutable once built.
Insets
Insets — padding or margin — per side, in logical pixels.
InsetsDirectional
Directional insets: start/end instead of left/right. In LTR, start is the left; in RTL it is the right. Resolved into concrete Insets at layout time.
LayerFilter
Everything a layer applies to its own pixels at compositing time. All three are optional and independent; LayerFilter::is_none is the fast path the renderer takes when nothing is asked for, which is nearly always.
LayerTransform
The transform applied to a layer (Primitive::Layer) at compositing time: an arbitrary Affine (translation, per-axis scale, rotation, or any composition of them) in screen pixels. The layer is first rendered flat into a texture, as with group opacity, then composited transformed — so a single pass transforms a whole subtree (rects, text, images) without touching any individual primitive’s shaders.
LinearGradient
A linear gradient: from the background (BoxDecoration::color) to end, along direction, expressed in [0,1]² space ([0,1] = top→bottom, [1,0] = left→right).
MaterialColor
A colour ramp: one hue in numbered steps, from the palest (50) to the darkest (900), plus the primary step the family is named after.
Path
A vector path: a sequence of PathVerb. Built in builder style (chainable), and consumed at render time.
Point
A 2D point.
Rect
An axis-aligned rectangle, in logical pixels.
ResolvedTextStyle
A TextStyle with every question answered: what to measure with, and what to draw.
Scene
A 2D scene: the declarative description of what to draw.
SemanticsProperties
A widget’s resolved semantic annotation, for accessibility.
ShaderMask
A colour blended over a subtree — the ShaderMask widget’s payload.
Size
A 2D size (width × height).
Stroke
An outline (the line a path is drawn with): colour and width, in pixels.
TextBlock
The box a block of text is laid out in: how wide it is, whether the text wraps at that width, and where the lines sit inside it. See Scene::text_block.
TextDecoration
A text’s decoration lines, which combine with one another. They have no effect on measurement: the text’s geometry does not change, and the lines are drawn by the backend from the baseline metrics.
TextRun
A text run ready to render: a fragment plus its typographic attributes and colour, all resolved — nothing left to inherit.
TextScaleGuard
Puts back the scale that was in force before install_text_scale, when dropped — including while a panic unwinds, so one bad frame cannot leave a stale scale installed for every frame after it.
TextSpan
A rich-text tree: each node carries a fragment of text, partial style overrides — whatever is unspecified inherits from the parent, so a .bold() child keeps its parent’s size — and children of its own.
TextStyle
The typographic attributes of a single line of text — every field optional.
TonalPalette
A tonal palette: one hue and chroma spread across the tone scale. tone(90) is very light, tone(10) very dark, and both read as one colour.
WindowInsets
The window insets, split by nature: padding is the area permanently taken by the system (status and navigation bars, the notch — all static), while view_insets is the area covered by transient UI, chiefly the soft keyboard. Avoiding the keyboard means keeping content clear of WindowInsets::safe.

Enums§

AlignmentGeometry
A resolvable anchor — either physical (Alignment) or directional (AlignmentDirectional). A widget accepts either one, through Into, and resolves it against the reading direction at render time.
BlendMode
How a source colour is combined with the destination underneath it.
BoxFit
How an image is fitted into its destination box — the same set of modes as the CSS object-fit property.
ClipShape
The clip shape of a Primitive::Layer, inscribed in its clip rectangle. Compositing multiplies the layer’s alpha by the shape’s coverage, with antialiased edges. This is the building block of the ClipRRect, ClipOval and ClipPath widgets.
ColorFilter
A function applied to every pixel of a subtree, independently of its neighbours: greyscale, a tint, a contrast curve.
Fetched
What is known about an image that has to be fetched before it can be shown.
FontFamily
A font family, as a style names it.
FontWeight
Font weight — a useful subset, mapped onto the CSS/OpenType weights.
FractionalMask
A MaskShader written in fractions of the box it covers — (0, 0) the top-left corner, (1, 1) the bottom-right.
ImageFilter
A filter that treats the subtree as an image, so a pixel’s result depends on its neighbours: a blur, a spread, a shrink.
MaskShader
The colour a ShaderMask blends over its subtree, as a two-stop fade.
Orientation
Display orientation, derived from the width-to-height ratio.
PathGradient
How a path’s fill fades: along a line, or outwards from a centre.
PathVerb
A single drawing command.
Primitive
A drawing primitive.
Role
An element’s semantic role (a subset aligned on AccessKit/ARIA roles: what a screen reader announces).
ShapeBorder
What shape a box is (shape_border.dart), and the edge around it.
SizeClass
A display-width band.
TextAlign
How the lines of a piece of text are aligned inside the box it was given.
TextDirection
The reading direction of text and layout. An ambient context: in RTL, rows, alignment and directional insets all flip horizontally.
TextOverflow
What becomes of text that does not fit the box it was given.
Toggled
The checked state of a toggleable control (checkbox, switch, radio).

Constants§

DEFAULT_IMAGE_CACHE_BYTES
The default ceiling on decoded network images held in memory: the reference’s own figure.
DEFAULT_LINE_HEIGHT
The line height a style that says nothing gets, as a multiple of the font size.
DEFAULT_TEXT_SIZE
The font size a text ends up at when nothing anywhere in the chain named one.

Functions§

cached
Resolves bytes to pixels once, returning the same handle on every later call.
fetched
What is known about the image at url, starting the fetch if this is the first ask.
fits
The rule for anything that measures itself: report a whole number of pixels, rounded up.
forget_cached_images
Empties the store. For tests that want a decode to happen again; an application has no reason to call it, since the entries are one per embedded asset and bounded by how many the binary carries.
forget_fetched_images
Forgets every fetched image and every remembered failure. For tests; see forget_cached_images.
image_cache_budget
The ceiling currently in force.
image_cache_bytes
The decoded bytes the store is currently holding.
images_in_flight
How many images are in flight right now.
install_text_scale
Installs the reader’s font-size setting until the returned guard is dropped.
set_image_cache_budget
Sets the ceiling on decoded network images held in memory, in bytes.
set_image_fetcher
Names the thing that gets bytes over the network.
surface_tint_opacity
How strongly a Material 3 surface is tinted at a given elevation.
text_scale
The reader’s font-size setting in force on this thread, or 1.0 outside any with_text_scale.
with_text_scale
Runs f with the reader’s font-size setting in force, restoring whatever was there before — including while a panic unwinds, so one bad frame cannot leave a stale scale installed for every frame after it.

Type Aliases§

ImageFetcher
Hands the bytes at url to the callback, once, from wherever suits the platform.
ImageHandle
A shared image handle: cheap to clone (reference counted), and stored as-is inside a crate::Primitive::Image.