diff --git a/README.md b/README.md index 13b1746..c190f9f 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,29 @@ fn main() { } ``` +## Spinner + +Spinners are used to indicate that a process is running. +Run example with [`cargo run --example spinner`](./examples/spinner.rs). + +![Spinner](./assets/spinner.gif) + +```rust +use std::{thread::sleep, time::Duration}; + +use demand::{Spinner, SpinnerStyle}; + +fn main() { + Spinner::new("Loading Data...") + .style(SpinnerStyle::line()) + .run(|| { + sleep(Duration::from_secs(2)); + }) + .expect("error running spinner"); + println!("Done!"); +} +``` + ## Themes Supply your own custom theme or choose from one of the predefined themes: diff --git a/assets/spinner.gif b/assets/spinner.gif new file mode 100644 index 0000000..dd0ece1 Binary files /dev/null and b/assets/spinner.gif differ diff --git a/assets/spinner.tape b/assets/spinner.tape new file mode 100644 index 0000000..d5f6594 --- /dev/null +++ b/assets/spinner.tape @@ -0,0 +1,73 @@ +# VHS documentation +# +# Output: +# Output .gif Create a GIF output at the given +# Output .mp4 Create an MP4 output at the given +# Output .webm Create a WebM output at the given +# +# Require: +# Require Ensure a program is on the $PATH to proceed +# +# Settings: +# Set FontSize Set the font size of the terminal +# Set FontFamily Set the font family of the terminal +# Set Height Set the height of the terminal +# Set Width Set the width of the terminal +# Set LetterSpacing Set the font letter spacing (tracking) +# Set LineHeight Set the font line height +# Set LoopOffset % Set the starting frame offset for the GIF loop +# Set Theme Set the theme of the terminal +# Set Padding Set the padding of the terminal +# Set Framerate Set the framerate of the recording +# Set PlaybackSpeed Set the playback speed of the recording +# Set MarginFill Set the file or color the margin will be filled with. +# Set Margin Set the size of the margin. Has no effect if MarginFill isn't set. +# Set BorderRadius Set terminal border radius, in pixels. +# Set WindowBar Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight) +# Set WindowBarSize Set window bar size, in pixels. Default is 40. +# Set TypingSpeed