Expand description
One-cell animations: an ordered list of frames, each with a glyph per glyph mode and an optional colour, played at a theme or literal frame time.
Every spinner style, the spinner’s finish and anything an application defines are the same
CellAnimation data. They are written in icon set and theme files, so a theme or an
application replaces a built-in animation the way it replaces an icon:
[animations.spinner-arc]
frame = "spinner" # a [motion] key, or a duration such as "80ms"
playback = "loop" # loop | once | bounce
colors = "step" # step | blend
rest = 1 # the frame shown with reduced motion, counted from 1
frames = [
{ unicode = "◜", ascii = "-" },
{ nerd = "\uEE07", unicode = "◠", ascii = "\\", color = "mix($accent, $fg, 40%)" },
{ ascii = "|", color = "#38BDF8", duration = "120ms" },
]- Glyphs.
asciiis required; a missingunicodefalls back toasciiand a missingnerdtounicode. Every glyph is exactly one cell, and none may be a bracket. - Colours are theme colour expressions:
$token,#RRGGBB,mix(a, b, N%)andpulse(a, b).$fgis the colour of the widget drawing the animation. A frame without a colour takes the widget’s colour. - Colour modes.
stepshows each frame in its own colour;blendmoves the colour smoothly towards the next frame’s colour while a frame is shown. - Playback.
looprepeats,onceplays once and rests on the last frame,bounceplays forward and back. - Reduced motion shows the
restframe (the first, or the last foronce) standing still; apulse()then shows its second colour.
Draw a named animation with PaintCx::animation, or
sample a CellAnimation directly with CellAnimation::sample.
Structs§
- Animated
Cell - One cell of a playing animation, as
PaintCx::animationreturns it. - Animation
Frame - One frame: its glyphs, and optionally its own colour and duration.
- Animation
Name - The name of a registered animation, such as
"spinner-arc". Widgets that play animations take anything that converts into one: a string or aSpinnerStyle. - Cell
Animation - A one-cell animation. See the module documentation for the file format.
- Cell
Color - The colour of a frame: a theme colour expression, resolved against the theme drawing it.
- Cell
Frame - What an animation shows at one moment.
Enums§
- Color
Mode - How colours move between frames.
- Frame
Time - How long a frame is shown: a
[motion]key of the theme, or a fixed duration. - Playback
- How the frames follow one another.
Constants§
- MAX_
FRAMES - The most frames one animation may have; a longer list is an error in a file.
Functions§
- check_
glyph - Checks that
glyphcan be themodeglyph of a frame: one grapheme, exactly one cell wide, not a bracket, and printable ASCII inGlyphMode::Ascii. - is_
valid_ name - Whether
namecan name an animation: lowercase letters, digits and-, like colour tokens. - parse_
animations - Reads a file holding only
[animations.<name>]tables, such as the animations an application or a tool saved. Returns the usable animations in file order and every problem found; a broken animation is skipped, a file that is not TOML yields no animations.