Documentation
¶
Overview ¶
Spring driven scalars and rectangles for terminal motion
Index ¶
Constants ¶
const ( // Angular frequency that settles most moves in about a third of a second DefaultFrequency = 13.0 // Damping ratio that overshoots slightly before coming to rest DefaultDamping = 0.8 )
Variables ¶
var ( // Chrome that keeps up with the hand, settled in a quarter second without overshoot Snappy = Spring{Frequency: 18, Damping: 1} // Fades and veils that ease in without a bounce, quick enough that a fade over the whole screen takes few frames Gentle = Spring{Frequency: 16, Damping: 1} // Refusals that swing a few times before resting Rattle = Spring{Frequency: 36, Damping: 0.2} )
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Schedules frames quickly while motion is active and slowly while the screen is at rest
func (*Clock) Accept ¶
Stamps a frame with its delta time, rejecting frames from stale schedules or other clocks
type FrameMsg ¶
Delivered once per animation frame with the seconds elapsed since the previous frame
type Rect ¶
type Rect struct {
X, Y, W, H Value
}
Box whose edges animate independently, with size springs that never overshoot
func NewRect ¶
Builds a resting rectangle in cells whose edges move critically damped, so a card never overshoots its place by a cell and comes back
func (Rect) Cells ¶
Current box rounded to whole cells, the far edges rounded on their own so neither side jitters
type Value ¶
Scalar that eases toward its target with damped spring motion
func NewValueWith ¶
Builds a resting scalar that moves with the spring
func (*Value) StepCells ¶
Advances a position in terminal cells by dt seconds, resting once it shows its target and has all but stopped, and reports whether it is still moving
func (*Value) StepLevels ¶
Advances a value drawn in steps of a levels-th of a unit by dt seconds, such as a fade drawn in a few shades or a share of a slide drawn in whole cells, resting once it shows the step of its target on its way there, and reports whether it is still moving. Meant for springs that do not overshoot, which never leave the step of their target once they reach it, so the frames of a tail that draws nothing new are not spent