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 = -1hugs the left,0centres,+1hugs the right;y = -1is the top,+1the bottom. Being continuous, it interpolates (crate::Lerp): aTween<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). - Alignment
Directional - A directional anchor: the horizontal axis is expressed start → end
rather than left → right.
x_start = -1hugs the start edge (left in LTR, right in RTL),+1the end edge. Resolved into a physicalAlignmentat 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.
- Border
Radius - Corner radii, per corner (logical px).
From<f32>covers the uniform case: anywhere a radius is expected, a plain10.0still works. - Border
Radius Directional - A corner radius named by the reading direction rather than by the wall
(
border_radius.dart:621). - Border
Side - 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
Colorconstants. - Hct
- A colour in HCT: CAM16 hue (degrees), CAM16 chroma, and L* tone.
- Image
Data - An image’s pixels: 8-bit RGBA, sRGB, row by row from the top-left corner
(
width * height * 4bytes). Immutable once built. - Insets
- Insets — padding or margin — per side, in logical pixels.
- Insets
Directional - Directional insets:
start/endinstead ofleft/right. In LTR,startis the left; in RTL it is the right. Resolved into concreteInsetsat layout time. - Layer
Filter - Everything a layer applies to its own pixels at compositing time. All three are
optional and independent;
LayerFilter::is_noneis the fast path the renderer takes when nothing is asked for, which is nearly always. - Layer
Transform - The transform applied to a layer (
Primitive::Layer) at compositing time: an arbitraryAffine(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. - Linear
Gradient - A linear gradient: from the background (
BoxDecoration::color) toend, alongdirection, expressed in[0,1]²space ([0,1]= top→bottom,[1,0]= left→right). - Material
Color - A colour ramp: one hue in numbered steps, from the palest (
50) to the darkest (900), plus theprimarystep 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.
- Resolved
Text Style - A
TextStylewith every question answered: what to measure with, and what to draw. - Scene
- A 2D scene: the declarative description of what to draw.
- Semantics
Properties - A widget’s resolved semantic annotation, for accessibility.
- Shader
Mask - A colour blended over a subtree — the
ShaderMaskwidget’s payload. - Size
- A 2D size (width × height).
- Stroke
- An outline (the line a path is drawn with): colour and width, in pixels.
- Text
Block - 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. - Text
Decoration - 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.
- Text
Scale Guard - 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. - Text
Span - 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. - Text
Style - The typographic attributes of a single line of text — every field optional.
- Tonal
Palette - 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. - Window
Insets - The window insets, split by nature:
paddingis the area permanently taken by the system (status and navigation bars, the notch — all static), whileview_insetsis the area covered by transient UI, chiefly the soft keyboard. Avoiding the keyboard means keeping content clear ofWindowInsets::safe.
Enums§
- Alignment
Geometry - A resolvable anchor — either physical (
Alignment) or directional (AlignmentDirectional). A widget accepts either one, throughInto, and resolves it against the reading direction at render time. - Blend
Mode - 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-fitproperty. - Clip
Shape - The clip shape of a
Primitive::Layer, inscribed in itscliprectangle. Compositing multiplies the layer’s alpha by the shape’s coverage, with antialiased edges. This is the building block of theClipRRect,ClipOvalandClipPathwidgets. - Color
Filter - 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.
- Font
Family - A font family, as a style names it.
- Font
Weight - Font weight — a useful subset, mapped onto the CSS/OpenType weights.
- Fractional
Mask - A
MaskShaderwritten in fractions of the box it covers —(0, 0)the top-left corner,(1, 1)the bottom-right. - Image
Filter - A filter that treats the subtree as an image, so a pixel’s result depends on its neighbours: a blur, a spread, a shrink.
- Mask
Shader - The colour a
ShaderMaskblends over its subtree, as a two-stop fade. - Orientation
- Display orientation, derived from the width-to-height ratio.
- Path
Gradient - How a path’s fill fades: along a line, or outwards from a centre.
- Path
Verb - 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).
- Shape
Border - What shape a box is (
shape_border.dart), and the edge around it. - Size
Class - A display-width band.
- Text
Align - How the lines of a piece of text are aligned inside the box it was given.
- Text
Direction - The reading direction of text and layout. An ambient context: in RTL, rows, alignment and directional insets all flip horizontally.
- Text
Overflow - 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
bytesto 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.0outside anywith_text_scale. - with_
text_ scale - Runs
fwith 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§
- Image
Fetcher - Hands the bytes at
urlto the callback, once, from wherever suits the platform. - Image
Handle - A shared image handle: cheap to clone (reference counted), and stored as-is
inside a
crate::Primitive::Image.