Spring

io.worxbend.tui.core.Spring
See theSpring companion object
final case class Spring(frequency: Double = ..., damping: Double = ..., deltaTime: Double = ...)

A damped-spring integrator (à la Charm's Harmonica) for physical, non-linear motion — scrolling, progress fills, layout transitions.

Unlike an Easing, a spring has no fixed duration: call step each tick with the current State and it eases toward target, overshooting or settling per frequency (stiffness) and damping (< 1 bouncy, 1 critically damped, > 1 sluggish). Integrated semi-implicitly, stable for the usual TUI tick rates.

deltaTime must be positive: a spring with a non-positive step can never advance, so the documented while !settled(...) do step(...) loop would hang. A defect in the caller, hence a construction-time throw.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def settled(position: Double, velocity: Double, target: Double, epsilon: Double = ...): Boolean

Whether the value has effectively settled on target (within epsilon of it and nearly at rest).

Whether the value has effectively settled on target (within epsilon of it and nearly at rest).

Attributes

def step(current: State, target: Double): State

The next State as the value eases one deltaTime step toward target — the integration loop is while !settled(...) do state = step(state, ...), with the position and velocity travelling together rather than as two bare doubles a caller has to keep in step by hand.

The next State as the value eases one deltaTime step toward target — the integration loop is while !settled(...) do state = step(state, ...), with the position and velocity travelling together rather than as two bare doubles a caller has to keep in step by hand.

Attributes

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product