pub struct CellAnimation { /* private fields */ }Expand description
A one-cell animation. See the module documentation for the file format.
use qframe::animation::{AnimationFrame, CellAnimation, CellColor, Playback};
let blink = CellAnimation::new()
.frame(AnimationFrame::new("*").unicode("●"))
.frame(AnimationFrame::new(".").unicode("·").color(CellColor::parse("$muted").expect("colour")))
.playback(Playback::Bounce);
assert_eq!(blink.frames().len(), 2);Implementations§
Source§impl CellAnimation
impl CellAnimation
Sourcepub fn sample(
&self,
theme: &Theme,
fg: Option<Rgb>,
now: Duration,
since: Option<Duration>,
) -> CellFrame
pub fn sample( &self, theme: &Theme, fg: Option<Rgb>, now: Duration, since: Option<Duration>, ) -> CellFrame
The frame and colour at now.
since is when the animation started (a time on the same clock as now, such as
PaintCx::now); None shows the rest frame standing still,
which is what reduced motion asks for. Looping spinners pass Duration::ZERO, so every
spinner on screen turns in step. Frames without a colour, and $fg in colour
expressions, take fg; a colour naming a token the theme lacks is treated the same way.
Pulses breathe over the theme’s motion.pulse-period on the now clock.
Source§impl CellAnimation
impl CellAnimation
Sourcepub fn to_toml(&self, name: &str) -> String
pub fn to_toml(&self, name: &str) -> String
The [animations.<name>] table for this animation, ready to paste into an icon set, theme
or animation file. Reading it back gives the same animation. Glyphs a frame leaves to its
fallback are left out, and Nerd Font glyphs from the private use areas are written as
\u escapes so they survive fonts and clipboards that cannot show them.
Source§impl CellAnimation
impl CellAnimation
Sourcepub fn new() -> Self
pub fn new() -> Self
An animation without frames, looping at the theme’s motion.spinner with step colours.
Sourcepub fn frame(self, frame: AnimationFrame) -> Self
pub fn frame(self, frame: AnimationFrame) -> Self
Adds a frame at the end.
Sourcepub fn frame_time(self, time: FrameTime) -> Self
pub fn frame_time(self, time: FrameTime) -> Self
How long each frame is shown, unless the frame has its own duration.
Sourcepub fn rest(self, index: usize) -> Self
pub fn rest(self, index: usize) -> Self
The frame shown with reduced motion, counted from 0. Without it the first frame rests,
or the last for Playback::Once.
Sourcepub fn frames(&self) -> &[AnimationFrame]
pub fn frames(&self) -> &[AnimationFrame]
The frames in order.
Sourcepub fn color_mode(&self) -> ColorMode
pub fn color_mode(&self) -> ColorMode
The colour mode.
Sourcepub fn rest_frame(&self) -> Option<usize>
pub fn rest_frame(&self) -> Option<usize>
The rest frame as set, counted from 0.
Sourcepub fn rest_index(&self) -> usize
pub fn rest_index(&self) -> usize
The frame shown standing still: the rest frame, else the first, or the last for
Playback::Once; always a valid index of a non-empty animation.
Trait Implementations§
Source§impl Clone for CellAnimation
impl Clone for CellAnimation
Source§fn clone(&self) -> CellAnimation
fn clone(&self) -> CellAnimation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CellAnimation
impl Debug for CellAnimation
Source§impl Default for CellAnimation
impl Default for CellAnimation
Source§fn default() -> CellAnimation
fn default() -> CellAnimation
impl Eq for CellAnimation
Source§impl PartialEq for CellAnimation
impl PartialEq for CellAnimation
impl StructuralPartialEq for CellAnimation
Auto Trait Implementations§
impl Freeze for CellAnimation
impl RefUnwindSafe for CellAnimation
impl Send for CellAnimation
impl Sync for CellAnimation
impl Unpin for CellAnimation
impl UnsafeUnpin for CellAnimation
impl UnwindSafe for CellAnimation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more