pub struct AnimatedIconData { /* private fields */ }Expand description
A mark that is drawn from a number: 0.0 is one state, 1.0 is the other, and
everything between is the way across.
It is Copy and costs nothing until AnimatedIconData::at is called. What comes
back from at is an ordinary IconData, so every widget that already takes an
icon takes a morphing one — an Icon, an
IconButton, a floating action button, a chip, a navigation
destination — with nothing added to any of them.
Implementations§
Source§impl AnimatedIconData
impl AnimatedIconData
Sourcepub const fn custom(draw: fn(f32) -> Path) -> Self
pub const fn custom(draw: fn(f32) -> Path) -> Self
A pair of the caller’s own: draw is handed a t in 0.0..=1.0 and returns the
outline for it, on the 24 × 24 grid, y downwards, filled by the non-zero rule.
A function pointer rather than a closure, so a pair stays a const and is
declared exactly where a bundled one would be.
use frus_core::{Path, Rect};
use frus_widgets::AnimatedIconData;
/// A bar that grows from nothing.
fn grow(t: f32) -> Path {
Path::rect(Rect::new(12.0 - 9.0 * t, 11.0, 18.0 * t, 2.0))
}
const GROW: AnimatedIconData = AnimatedIconData::custom(grow);
assert!(GROW.at(0.0).path().verbs().len() == GROW.at(1.0).path().verbs().len());Sourcepub const fn mirrored(self) -> Self
pub const fn mirrored(self) -> Self
The same pair, declared to carry a direction — turned round in a right-to-left
reading order, like IconData::mirrored. The whole
animation is mirrored, at every t, because a mark that points somewhere points
there all the way across.
Sourcepub const fn matches_text_direction(self) -> bool
pub const fn matches_text_direction(self) -> bool
Whether this pair is turned round for a right-to-left reading order.