Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.
LOOM Unreleased (PR #2) / ANIMATION
SymbolAnimation
No timer is started. Sample from your own elapsed clock and schedule another draw using nextFrame. Empty frame lists become one blank frame. Nonpositive/non-finite frame durations become 0.133 seconds; negative/non-finite elapsed times use the first frame. A one-frame animation is static.
Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.
Example
let animation = SymbolAnimation.spinner(style: Style(foreground: .rgb(237, 166, 98)))
let sample = animation.sample(at: 1.25)
_ = (sample.symbol, animation.nextFrame(after: 1.25))Members on this page
Feature guides and release status
SymbolAnimation
struct SymbolAnimationConforms to: Swift.Sendable, Swift.SendableMetatype.
A deterministic sequence of terminal symbols and styles, driven by the caller's clock.
This value owns no timer. Schedule only while visible, and render at frame boundaries.
Source · SymbolAnimation.swift:6Sample
struct SampleConforms to: Swift.Equatable, Swift.Sendable, Swift.SendableMetatype.
One animation frame’s symbol and style. Construct samples for a custom SymbolAnimation.
Source · SymbolAnimation.swift:7Sample.symbol
let symbol: StringThe visible grapheme or symbol string.
Source · SymbolAnimation.swift:8Sample.style
let style: StyleVisual attributes used when painting this value.
Source · SymbolAnimation.swift:9Sample.init(_:style:)
init(_ symbol: String, style: Style = Style())Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (2)
symbol- Argument type and any default are shown in the declaration; see the behavior notes above.
style- Text/cell appearance.
frames
let frames: [Sample]Samples used by the looping animation.
Source · SymbolAnimation.swift:17frameDuration
let frameDuration: TimeIntervalSeconds per sample after initializer validation.
Source · SymbolAnimation.swift:18init(frames:frameDuration:)
init(frames: [Sample], frameDuration: TimeInterval)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (2)
frames- Animation samples in loop order.
frameDuration- Seconds per animation sample.
sample(at:)
func sample(at elapsed: TimeInterval) -> SampleReturns the current sample, wrapping over frames by elapsed time. Negative/non-finite elapsed time uses frame zero.
Parameters (1)
at- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns SymbolAnimation.Sample.
nextFrame(after:)
func nextFrame(after elapsed: TimeInterval) -> TimeInterval?Seconds until the next frame boundary; nil for a static sequence.
Parameters (1)
after- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns TimeInterval?.
spinner(style:)
static func spinner(style: Style = Style()) -> SymbolAnimationBraille activity indicator, approximately 7.5 frames per second.
Parameters (1)
style- Text/cell appearance.
Returns SymbolAnimation.
activity(style:)
static func activity(style: Style = Style()) -> SymbolAnimationSlower background activity cycle, approximately one loop per second.
Parameters (1)
style- Text/cell appearance.
Returns SymbolAnimation.
pulse(symbol:low:high:style:)
static func pulse(symbol: String = "◆", low: UInt8 = 80, high: UInt8 = 160, style: Style = Style()) -> SymbolAnimationSmooth foreground brightness pulse; never changes the terminal background.
Parameters (4)
symbol- Argument type and any default are shown in the declaration; see the behavior notes above.
low- Argument type and any default are shown in the declaration; see the behavior notes above.
high- Argument type and any default are shown in the declaration; see the behavior notes above.
style- Text/cell appearance.
Returns SymbolAnimation.