pub struct FluxSpinner<'a> { /* private fields */ }Expand description
A compact braille rotation spinner.
Each character cell shows a full 8-dot braille glyph (⣿) with one dot
missing; the gap rotates through all eight positions every 8 steps,
creating an animated “spinning hole” effect.
Direction is controlled by Spin:
Spin::Clockwise(default) — gap moves clockwise:⣾ ⣷ ⣯ ⣟ ⡿ ⢿ ⣽ ⣻Spin::CounterClockwise— gap moves counter-clockwise:⣾ ⣻ ⣽ ⢿ ⡿ ⣟ ⣯ ⣷
Scaling up via width / height
adds a configurable per-cell phase offset
(phase_step) so adjacent characters are
staggered in time, producing a smooth diagonal wave across the spinner
block. The wave direction follows the spin direction.
§Default values
| Field | Default |
|---|---|
width | 1 |
height | 1 |
spin | Spin::Clockwise |
color | Color::Cyan |
ticks_per_step | 1 |
phase_step | 1 |
frames | FluxFrames::BRAILLE |
§Examples
use tui_spinner::{FluxFrames, FluxSpinner, Spin};
// Minimal 1×1 clockwise spinner
let s = FluxSpinner::new(42);
// 8-wide counter-clockwise wave
let wave = FluxSpinner::new(42)
.width(8)
.spin(Spin::CounterClockwise)
.phase_step(1);
// Custom frame sequence
let line = FluxSpinner::new(42).frames(FluxFrames::LINE);Implementations§
Source§impl<'a> FluxSpinner<'a>
impl<'a> FluxSpinner<'a>
Sourcepub fn new(tick: u64) -> Self
pub fn new(tick: u64) -> Self
Creates a new FluxSpinner with default settings: 1 × 1,
clockwise, cyan, 1 tick per frame, phase step 1.
§Examples
use tui_spinner::FluxSpinner;
let s = FluxSpinner::new(0);Sourcepub fn width(self, w: usize) -> Self
pub fn width(self, w: usize) -> Self
Sets the width in character columns (default 1).
§Examples
use tui_spinner::FluxSpinner;
let wide = FluxSpinner::new(0).width(6);Sourcepub fn height(self, h: usize) -> Self
pub fn height(self, h: usize) -> Self
Sets the height in character rows (default 1).
§Examples
use tui_spinner::FluxSpinner;
let tall = FluxSpinner::new(0).height(3);Sourcepub const fn spin(self, spin: Spin) -> Self
pub const fn spin(self, spin: Spin) -> Self
Sets the rotation direction (default Spin::Clockwise).
Also reverses the phase-wave direction for multi-cell spinners.
§Examples
use tui_spinner::{FluxSpinner, Spin};
let cw = FluxSpinner::new(0).spin(Spin::Clockwise);
let ccw = FluxSpinner::new(0).spin(Spin::CounterClockwise);Sourcepub const fn color(self, color: Color) -> Self
pub const fn color(self, color: Color) -> Self
Sets the spinner colour (default Color::Cyan).
§Examples
use ratatui::style::Color;
use tui_spinner::FluxSpinner;
let s = FluxSpinner::new(0).color(Color::White);Sourcepub fn ticks_per_step(self, n: u64) -> Self
pub fn ticks_per_step(self, n: u64) -> Self
Sets how many ticks each frame is held (default 1; higher = slower).
§Examples
use tui_spinner::FluxSpinner;
let slow = FluxSpinner::new(0).ticks_per_step(4);Sourcepub const fn phase_step(self, step: u8) -> Self
pub const fn phase_step(self, step: u8) -> Self
Sets the frame offset between adjacent cells (default 1).
| value | effect |
|---|---|
0 | All cells synchronised — a uniform pulsing block |
1 | Smooth diagonal wave (default) |
2 | Faster / wider wave |
4 | Anti-phase: neighbouring cells spin opposite (⣾/⡿) |
The wave travels in the spin direction.
§Examples
use tui_spinner::FluxSpinner;
let sync = FluxSpinner::new(0).width(4).phase_step(0);
let wave = FluxSpinner::new(0).width(4).phase_step(1);
let anti = FluxSpinner::new(0).width(4).phase_step(4);Sourcepub fn frames(self, frames: &'static [char]) -> Self
pub fn frames(self, frames: &'static [char]) -> Self
Sets the frame sequence (default FluxFrames::BRAILLE).
Use one of the FluxFrames presets or supply any
&'static [char] slice for a fully custom animation.
§Examples
use tui_spinner::{FluxSpinner, FluxFrames};
let orbit = FluxSpinner::new(0).frames(FluxFrames::ORBIT);
let line = FluxSpinner::new(0).frames(FluxFrames::LINE);
let custom = FluxSpinner::new(0).frames(&['◐', '◓', '◑', '◒']);Sourcepub fn style<S: Into<Style>>(self, style: S) -> Self
pub fn style<S: Into<Style>>(self, style: S) -> Self
Sets the base style applied to the widget area.
Trait Implementations§
Source§impl<'a> Clone for FluxSpinner<'a>
impl<'a> Clone for FluxSpinner<'a>
Source§fn clone(&self) -> FluxSpinner<'a>
fn clone(&self) -> FluxSpinner<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for FluxSpinner<'a>
impl<'a> Debug for FluxSpinner<'a>
Source§impl Styled for FluxSpinner<'_>
impl Styled for FluxSpinner<'_>
Source§impl Widget for &FluxSpinner<'_>
impl Widget for &FluxSpinner<'_>
Auto Trait Implementations§
impl<'a> Freeze for FluxSpinner<'a>
impl<'a> RefUnwindSafe for FluxSpinner<'a>
impl<'a> Send for FluxSpinner<'a>
impl<'a> Sync for FluxSpinner<'a>
impl<'a> Unpin for FluxSpinner<'a>
impl<'a> UnsafeUnpin for FluxSpinner<'a>
impl<'a> UnwindSafe for FluxSpinner<'a>
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<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 moreSource§impl<T, U> Stylize<'_, T> for Uwhere
U: Styled<Item = T>,
impl<T, U> Stylize<'_, T> for Uwhere
U: Styled<Item = T>,
fn bg<C>(self, color: C) -> T
fn fg<C>(self, color: C) -> T
fn add_modifier(self, modifier: Modifier) -> T
fn remove_modifier(self, modifier: Modifier) -> T
fn reset(self) -> T
Source§fn on_magenta(self) -> T
fn on_magenta(self) -> T
magenta.Source§fn on_dark_gray(self) -> T
fn on_dark_gray(self) -> T
dark_gray.Source§fn on_light_red(self) -> T
fn on_light_red(self) -> T
light_red.Source§fn light_green(self) -> T
fn light_green(self) -> T
light_green.Source§fn on_light_green(self) -> T
fn on_light_green(self) -> T
light_green.Source§fn light_yellow(self) -> T
fn light_yellow(self) -> T
light_yellow.Source§fn on_light_yellow(self) -> T
fn on_light_yellow(self) -> T
light_yellow.Source§fn light_blue(self) -> T
fn light_blue(self) -> T
light_blue.Source§fn on_light_blue(self) -> T
fn on_light_blue(self) -> T
light_blue.Source§fn light_magenta(self) -> T
fn light_magenta(self) -> T
light_magenta.Source§fn on_light_magenta(self) -> T
fn on_light_magenta(self) -> T
light_magenta.Source§fn light_cyan(self) -> T
fn light_cyan(self) -> T
light_cyan.Source§fn on_light_cyan(self) -> T
fn on_light_cyan(self) -> T
light_cyan.Source§fn not_italic(self) -> T
fn not_italic(self) -> T
italic modifier.Source§fn underlined(self) -> T
fn underlined(self) -> T
underlined modifier.Source§fn not_underlined(self) -> T
fn not_underlined(self) -> T
underlined modifier.Source§fn slow_blink(self) -> T
fn slow_blink(self) -> T
slow_blink modifier.Source§fn not_slow_blink(self) -> T
fn not_slow_blink(self) -> T
slow_blink modifier.Source§fn rapid_blink(self) -> T
fn rapid_blink(self) -> T
rapid_blink modifier.Source§fn not_rapid_blink(self) -> T
fn not_rapid_blink(self) -> T
rapid_blink modifier.Source§fn not_reversed(self) -> T
fn not_reversed(self) -> T
reversed modifier.hidden modifier.hidden modifier.Source§fn crossed_out(self) -> T
fn crossed_out(self) -> T
crossed_out modifier.Source§fn not_crossed_out(self) -> T
fn not_crossed_out(self) -> T
crossed_out modifier.