class

CryTUI::Widgets::RingEngine

Inherits Reference < Object

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

new(size : Int32, centre : Centre)
Source

Class methods

centre_cells(size : Int32, width : Int32) : Tuple(Array(RingCoord), RingCoord, RingCoord)
Source
char_size(size : Int32) : Tuple(Int32, Int32)

The rendered size in character cells, so a caller can reserve space for a spinner before drawing it.

Source
dimension(size : Int32) : Int32

Dots across the ring for a given thickness. Both the width and the height of the grid, since the shape is square.

Source
head_map(width : Int32, height : Int32, size : Int32) : Hash(RingCoord, RingCoord)

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.

Source
period(size : Int32, head_map : Hash(RingCoord, RingCoord)) : Int32

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.

Source
rotate(nodes : Array(RingCoord), rotation : Hash(RingCoord, RingCoord)) : Array(RingCoord) | Nil

A corner only turns when every dot of the bar is on it; a partially entered corner keeps travelling straight.

Source
step(nodes : Array(RingCoord), rotation : Hash(RingCoord, RingCoord)) : Array(RingCoord)
Source
tail_map(width : Int32, height : Int32, size : Int32) : Hash(RingCoord, RingCoord)
Source
vertical_offset(size : Int32) : Int32

The thinnest ring is two dot-rows short of a whole braille cell, so it is pushed down to sit on the cell boundary instead of straddling it.

Source

Instance methods

advance(steps : UInt64) : Nil

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.

Source
grid
Source
has_centre?
Source
head
Source
lines(arc_color : Color, dim_color : Color, alignment : Alignment) : Array(Line)
Source
tail
Source
walk
Source