Skip to main content

Module util

Module util 

Source
Expand description

Numeric helpers: “nice” tick generation and number formatting.

Functions§

darken
Darken a color toward black by amount (0..=1); used for unfilled tracks.
format_compact
Compact human format: 1.5k, 2.3M, 4B.
format_tick
Format a tick value with just enough decimals for the given step.
mix
Mix a toward b by t (0 = a, 1 = b); the result is always Rgb.
nice_bounds
Expand [min, max] outward to the nearest “nice” tick multiples.
nice_step
Round a raw step up to a “nice” value (1, 2, 5 × 10ⁿ).
nice_ticks
Generate roughly count nicely spaced tick values inside [min, max].
tick_step
Step between the first two ticks (or 1.0).
to_rgb
Approximate RGB of a terminal color (named colors use common xterm values).