pub struct CircleSpinner<'a> { /* private fields */ }Expand description
A spinner whose arc rotates clockwise around a circular braille-dot ring.
Uses a 1:1 dot pitch which, after braille packing (2 dot-cols per char-col, 4 dot-rows per char-row) and the ~2× terminal cell aspect ratio, produces a visually round circle.
There is no centre fill — only the rotating arc on the ring is drawn.
§Layout
The rendered size in terminal characters is approximately:
- columns:
⌈(2r + 1) / 2⌉ - rows:
⌈(2r + 1) / 4⌉
Use CircleSpinner::char_size to query the exact dimensions.
§Examples
use ratatui::style::Color;
use ratatui::Frame;
use ratatui::layout::Rect;
use tui_spinner::CircleSpinner;
fn draw(frame: &mut Frame, area: Rect, tick: u64) {
frame.render_widget(
CircleSpinner::new(tick)
.radius(6)
.arc_color(Color::Cyan)
.dim_color(Color::DarkGray),
area,
);
}Implementations§
Source§impl<'a> CircleSpinner<'a>
impl<'a> CircleSpinner<'a>
Sourcepub fn new(tick: u64) -> Self
pub fn new(tick: u64) -> Self
Creates a new CircleSpinner with defaults: radius 4, clockwise spin,
white arc, dark-gray dim ring, 1 tick per step, auto arc length.
§Examples
use tui_spinner::CircleSpinner;
let spinner = CircleSpinner::new(42);Sourcepub fn radius(self, r: usize) -> Self
pub fn radius(self, r: usize) -> Self
Sets the circle radius in braille dots (default: 4, minimum: 1).
§Examples
use tui_spinner::CircleSpinner;
let big = CircleSpinner::new(0).radius(8);Sourcepub fn arc_len(self, len: usize) -> Self
pub fn arc_len(self, len: usize) -> Self
Sets the number of perimeter dots in the bright arc (0 = auto ¼ of the total perimeter length).
Sourcepub const fn spin(self, spin: Spin) -> Self
pub const fn spin(self, spin: Spin) -> Self
Sets the spin direction (default: Spin::Clockwise).
§Examples
use tui_spinner::{CircleSpinner, Spin};
let ccw = CircleSpinner::new(0).spin(Spin::CounterClockwise);Sourcepub fn ticks_per_step(self, n: u64) -> Self
pub fn ticks_per_step(self, n: u64) -> Self
Sets how many ticks each arc step is held (default: 1, higher = slower).
Sourcepub const fn arc_color(self, color: Color) -> Self
pub const fn arc_color(self, color: Color) -> Self
Sets the colour of the rotating bright arc (default: Color::White).
§Examples
use ratatui::style::Color;
use tui_spinner::CircleSpinner;
let spinner = CircleSpinner::new(0).arc_color(Color::Cyan);Sourcepub const fn dim_color(self, color: Color) -> Self
pub const fn dim_color(self, color: Color) -> Self
Sets the colour of the dim background ring (default: Color::DarkGray).
§Examples
use ratatui::style::Color;
use tui_spinner::CircleSpinner;
let spinner = CircleSpinner::new(0).dim_color(Color::DarkGray);Sourcepub const fn alignment(self, alignment: Alignment) -> Self
pub const fn alignment(self, alignment: Alignment) -> Self
Sets the horizontal alignment of the rendered output (default: left).
Sourcepub fn char_size(&self) -> (u16, u16)
pub fn char_size(&self) -> (u16, u16)
Returns the exact rendered size in terminal characters (cols, rows).
§Examples
use tui_spinner::CircleSpinner;
let (cols, rows) = CircleSpinner::new(0).radius(4).char_size();
// dot_cols = 2*4+1 = 9, char_cols = ceil(9/2) = 5
// dot_rows = 2*4+1 = 9, char_rows = ceil(9/4) = 3
assert_eq!(cols, 5);
assert_eq!(rows, 3);Trait Implementations§
Source§impl<'a> Clone for CircleSpinner<'a>
impl<'a> Clone for CircleSpinner<'a>
Source§fn clone(&self) -> CircleSpinner<'a>
fn clone(&self) -> CircleSpinner<'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 CircleSpinner<'a>
impl<'a> Debug for CircleSpinner<'a>
Source§impl Styled for CircleSpinner<'_>
impl Styled for CircleSpinner<'_>
Source§impl Widget for &CircleSpinner<'_>
impl Widget for &CircleSpinner<'_>
Auto Trait Implementations§
impl<'a> Freeze for CircleSpinner<'a>
impl<'a> RefUnwindSafe for CircleSpinner<'a>
impl<'a> Send for CircleSpinner<'a>
impl<'a> Sync for CircleSpinner<'a>
impl<'a> Unpin for CircleSpinner<'a>
impl<'a> UnsafeUnpin for CircleSpinner<'a>
impl<'a> UnwindSafe for CircleSpinner<'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.