Skip to main content

activity_lit

Function activity_lit 

Source
pub fn activity_lit(elapsed: Duration, reduced: bool) -> bool
Expand description

Whether the activity mark is lit, this far into a wait.

The one place the blink’s phase is worked out, so that piece::activity can stay a pure drawing and this crate can still hold no clock: the caller says how long the wait has run and gets back which of the two cells to draw.

The cadence is makeover_timing::Cadence::Activity, a half-period, and is deliberately not a number chosen here. Three renderers draw this mark and one of them is a browser running it off a CSS custom property; a terminal that picked its own would be a second heartbeat for one wait.

reduced returns a lit mark, always. A reader asking for less motion has asked for the movement to stop, not for the information to go away, which is the whole argument on makeover_timing::activity_blink. A terminal has no prefers-reduced-motion to read, so the preference arrives as a bool from whatever the host asked its own platform.

use makeover_tui::activity_lit;
use std::time::Duration;

assert!(activity_lit(Duration::from_millis(0), false));
assert!(!activity_lit(Duration::from_millis(600), false));
assert!(activity_lit(Duration::from_millis(1100), false));
// Motion off: lit, and it stays lit.
assert!(activity_lit(Duration::from_millis(600), true));