beamtea_progress (beamtea v0.1.2)

View Source

A bubble: a horizontal progress bar with an electric gradient.

Stateless with respect to time — set the percentage (0.0–1.0) from your own model and render. Pair it with a beamtea:every/2 timer to animate.

     P0 = beamtea_progress:new(#{width => 40}),
     P1 = beamtea_progress:set(0.42, P0),
     beamtea_progress:view(P1)   %% => "██████░░░░░  42%"

Summary

Functions

Add Delta to the current fraction (clamped).

Equivalent to new(#{}).

Options: width (default 40), full/empty glyphs, gradient ({FromRGB, ToRGB}, each an {R,G,B} triple — interpolated in 24-bit truecolor), empty_color (xterm-256 index), show_percent.

The current fraction.

Set the fill fraction, clamped to [0.0, 1.0].

Render the bar (with a trailing percentage unless disabled).

Types

model/0

-opaque model()

rgb/0

-type rgb() :: {0..255, 0..255, 0..255}.

Functions

incr(Delta, M)

-spec incr(number(), model()) -> model().

Add Delta to the current fraction (clamped).

new()

-spec new() -> model().

Equivalent to new(#{}).

new(Opts)

-spec new(map()) -> model().

Options: width (default 40), full/empty glyphs, gradient ({FromRGB, ToRGB}, each an {R,G,B} triple — interpolated in 24-bit truecolor), empty_color (xterm-256 index), show_percent.

percent(_)

-spec percent(model()) -> float().

The current fraction.

set(P, M)

-spec set(number(), model()) -> model().

Set the fill fraction, clamped to [0.0, 1.0].

view(_)

-spec view(model()) -> iodata().

Render the bar (with a trailing percentage unless disabled).