CryTUI::Widgets::RingEngine
The arc engine behind SquareSpinner and RectSpinner.
A size-thick bar of dots (the head) walks the perimeter lighting cells
while a second bar (the tail) trails behind clearing them, so the lit
region is an arc chasing itself around the ring. Straight runs move the
bar one dot at a time; the corners are lookup tables that rotate the bar
from one edge onto the next.
Constructors
Class methods
The rendered size in character cells, so a caller can reserve space for a spinner before drawing it.
Dots across the ring for a given thickness. Both the width and the height of the grid, since the shape is square.
Corner tables. Each entry rotates the bar off the edge it just finished and onto the next one; anything not in the table is a straight run.
Walks a throwaway bar around the ring to find how many steps a full revolution takes. Cheap enough to redo per frame -- the largest ring is a few hundred steps -- and it keeps the period honest if the corner tables ever change.
A corner only turns when every dot of the bar is on it; a partially entered corner keeps travelling straight.
Instance methods
Replays steps walks, folding a long-running tick back into one
revolution.
The widget is stateless -- every frame rebuilds the engine and replays the whole tick -- so an hour-old TUI would otherwise pay an hour of walks per frame. The walk is only periodic once the tail has cleared the initial spoke, which is why the first revolution is always replayed in full and only the remainder is folded.