Skip to content

SpinnerStyle

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

Defines a spinner animation style as a sequence of frames.

csharp
public sealed class SpinnerStyle

Inheritance

ObjectSpinnerStyle

Constructors

SpinnerStyle(params string[])

Creates a custom spinner style with default settings (80ms, no auto-reverse).

Parameters:

  • frames (String[]): The animation frames to cycle through.
csharp
public SpinnerStyle(params string[] frames)

SpinnerStyle(TimeSpan, bool, params string[])

Creates a custom spinner style with the specified interval and auto-reverse setting.

Parameters:

  • interval (TimeSpan): Suggested time between frame changes.
  • autoReverse (Boolean): Whether to ping-pong instead of loop.
  • frames (String[]): The animation frames to cycle through.
csharp
public SpinnerStyle(TimeSpan interval, bool autoReverse, params string[] frames)

SpinnerStyle(TimeSpan, params string[])

Creates a custom spinner style with the specified interval.

Parameters:

  • interval (TimeSpan): Suggested time between frame changes.
  • frames (String[]): The animation frames to cycle through.
csharp
public SpinnerStyle(TimeSpan interval, params string[] frames)

Properties

Arrow

Arrow rotation (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Arrow { get; }

AutoReverse

Gets whether the animation should reverse (ping-pong) instead of looping.

Returns: Boolean

csharp
public bool AutoReverse { get; }

Bounce

Bouncing bar (auto-reverses for smooth bounce)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Bounce { get; }

BouncingBall

Bouncing ball in brackets (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle BouncingBall { get; }

Circle

Quarter circle rotation (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Circle { get; }

Dots

Braille dot pattern (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Dots { get; }

DotsScrolling

Scrolling braille dots (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle DotsScrolling { get; }

Frames

Gets the animation frames for this spinner style.

Returns: IReadOnlyList<String>

csharp
public IReadOnlyList<string> Frames { get; }

GrowHorizontal

Horizontal bar growth (auto-reverses)

Returns: SpinnerStyle

csharp
public static SpinnerStyle GrowHorizontal { get; }

GrowVertical

Vertical bar growth (auto-reverses)

Returns: SpinnerStyle

csharp
public static SpinnerStyle GrowVertical { get; }

Interval

Gets the suggested interval between frame changes for smooth animation.

Returns: TimeSpan

csharp
public TimeSpan Interval { get; }

Line

Classic ASCII line spinner: | / - \ (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Line { get; }

LoadingBar

Loading bar (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle LoadingBar { get; }

Segments

Segmented blocks (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Segments { get; }

Square

Square corner rotation (loops)

Returns: SpinnerStyle

csharp
public static SpinnerStyle Square { get; }

Methods

GetFrame(int)

Gets the frame at the given index, handling auto-reverse if enabled.

Parameters:

  • frameIndex (Int32): The frame index (any integer, wraps/bounces automatically).

Returns: String

The frame string at that index.

csharp
public string GetFrame(int frameIndex)

Remarks

SpinnerStyle provides built-in styles via static properties (e.g., , ) and supports custom styles via the constructor.

Each style includes a suggested for smooth animation and an flag to control whether the animation ping-pongs or loops.

Examples

Using a built-in style:

csharp
ctx.Spinner(SpinnerStyle.Dots, frameIndex)

Creating a custom style:

csharp
var moonPhases = new SpinnerStyle(
    TimeSpan.FromMilliseconds(500),
    "🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘");
ctx.Spinner(moonPhases, frameIndex)

Released under the MIT License.