Skip to main content

CellAnimation

Struct CellAnimation 

Source
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

Source

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

Source

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

Source

pub fn new() -> Self

An animation without frames, looping at the theme’s motion.spinner with step colours.

Source

pub fn frame(self, frame: AnimationFrame) -> Self

Adds a frame at the end.

Source

pub fn frame_time(self, time: FrameTime) -> Self

How long each frame is shown, unless the frame has its own duration.

Source

pub fn playback(self, playback: Playback) -> Self

How the frames follow one another.

Source

pub fn colors(self, colors: ColorMode) -> Self

How colours move between frames.

Source

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.

Source

pub fn frames(&self) -> &[AnimationFrame]

The frames in order.

Source

pub fn time(&self) -> FrameTime

The frame time.

Source

pub fn play_mode(&self) -> Playback

The playback.

Source

pub fn color_mode(&self) -> ColorMode

The colour mode.

Source

pub fn rest_frame(&self) -> Option<usize>

The rest frame as set, counted from 0.

Source

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.

Source

pub fn glyph(&self, index: usize, mode: GlyphMode) -> &str

The glyph of frame index in mode; empty when there is no such frame.

Trait Implementations§

Source§

impl Clone for CellAnimation

Source§

fn clone(&self) -> CellAnimation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CellAnimation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CellAnimation

Source§

fn default() -> CellAnimation

Returns the “default value” for a type. Read more
Source§

impl Eq for CellAnimation

Source§

impl PartialEq for CellAnimation

Source§

fn eq(&self, other: &CellAnimation) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CellAnimation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.