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;pub use platform::debug_default_target_platform_override;pub use platform::default_target_platform;pub use platform::set_debug_default_target_platform_override;pub use platform::Platform;pub use platform::TargetPlatform;pub use platform::IS_WEB;
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 box’s border, side by side — the reference’s
Border(box_border.dart:431): each of the four sides its own colour and width. - Border
Directional - A box’s border, by the line’s start and end — the reference’s
BorderDirectional(box_border.dart:799): the start side is the left in a left-to-right script and the right in a right-to-left one. - 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 box — the reference’s
BoxDecoration(box_decoration.dart:81). - 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. - Decode
Size - The size an image is decoded at, in physical pixels: the full size of the file, or a smaller one that the place it is shown at needs.
- Decoration
Image - A picture painted as a box’s background — the reference’s
DecorationImage. - Fitted
Sizes - The two sizes a fit settles on — the reference’s
FittedSizes. - Gradient
Ramp - A gradient with any number of stops, for a path: its shape, its colours, what it does past its ends, and where it sits.
- 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. - Image
Piece - One part of a picture drawn somewhere: where, and which part, in
0..1of the picture (a negative width walks it backwards, which is how a picture is mirrored). - 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 gradient along a line, from
begintoend(gradient.dart’sLinearGradient). Unset, from the centre of the left side to the centre of the 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. - Platform
- Facts about the machine the application runs on, fixed for the life of the
process. Unlike
TargetPlatform, nothing overrides them. - Point
- A 2D point.
- Radial
Gradient - A gradient round a centre (
gradient.dart’sRadialGradient): the first colour atcenter, the last on the circleradiusround it. With afocalpoint, the first colour is on the circlefocal_radiusround that point instead, and the gradient runs between the two circles. - 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, width, in pixels, and how its ends are drawn.
- Sweep
Gradient - A gradient turning round a centre (
gradient.dart’sSweepGradient): fromstart_angletoend_angle, in radians clockwise from the right. - 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.
- Blur
Style - Which side of a shape a blur keeps (milestone 645), the reference’s
BlurStyle. - BoxBorder
- A box’s border, by its physical sides or by the line’s start and end.
- BoxFit
- How an image is fitted into its destination box — the same set of modes as the
CSS
object-fitproperty. - BoxShape
- The shape a box decoration paints — the reference’s
BoxShape(box_border.dart:26). - 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.
- Fill
Rule - Which points a filled path covers, where its contours cross or nest.
- 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. - Gradient
- Any of the three.
- 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.
- Image
Repeat - How a picture fills the room its fit leaves: once, or repeated across, down, or both
— the reference’s
ImageRepeat. - Insets
Geometry - Insets that are either physical (
Insets) or directional (InsetsDirectional). A widget accepts either one — or one number for all four sides — throughInto, and resolves it against the reading direction at layout time. - 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.
- Ramp
Shape - Where a
GradientRamp’s colours run. - 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.
- Stroke
Cap - How an open line ends — the reference’s
StrokeCap(milestone 630). - Target
Platform - The platforms whose conventions a widget can follow.
- 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.
- Tile
Mode - What a gradient does past its ends (
dart:ui’sTileMode). - 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.
- IS_WEB
- Whether this binary runs in a browser. A constant: a build is for the web or not.
- MAX_
IMAGE_ TILES - The most tiles one repeated picture draws. A one-pixel pattern repeated over a large box would otherwise be millions of draws; past this, the rest of the box stays empty.
Functions§
- apply_
box_ fit - Fits
inputintooutputbyfit— the reference’sapplyBoxFit. - cached
- Resolves
bytesto pixels once, returning the same handle on every later call. - cached_
at cached, at aDecodeSize: the same bytes decoded at two sizes are two entries, andloadis the one that decodes atsize.- debug_
default_ target_ platform_ override - The override of
default_target_platform, if one is set. - decoded_
at cached_at, decoding on a background thread whenin_the_backgroundsays so:Fetched::Loadinguntil the pixels are there, and the frames keep coming meanwhile (images_in_flightcounts it).- default_
target_ platform - The platform whose conventions an application follows unless its theme says otherwise: the debug override if one is set, else the browser’s operating system on the web, else the platform the binary was built for.
- fetched
- What is known about the image at
url, starting the fetch if this is the first ask. - fetched_
at fetched, at aDecodeSize:decodeis handed the size along with the bytes.- 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 size, and
bounded by how many the binary carries.
trim_image_cachesis the one for memory. - 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.
- paint_
elevation - Paints the shadows of a surface
elevationhigh, with cornersradius, behindrect:BoxShadow::for_elevation’s three, each asBoxDecorationpaints one. Nothing at a height of nought or in a colour with no opacity (milestone 606). - set_
debug_ default_ target_ platform_ override - Makes
default_target_platformreportplatform, or, withNone, what it would report on its own: for trying another platform’s behaviour during development, and for tests. It is process-wide, so a test that sets it resets it before it returns. - 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. - tile
- Tiles
tpast the gradient’s ends (dart:ui’sTileMode):Nonewhere nothing is drawn. - trim_
image_ caches - Gives back every decoded image nobody is showing: what the system asks for when it is short of memory.
- 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.