Documentation
¶
Overview ¶
Package motion holds the two solvers animation is built on, a damped harmonic spring and a CSS cubic-bezier timing function, as pure maths over floats. lys-ui's anim and lys-wm's anim keep their own configuration on top: a response and damping fraction there, stiffness, damping and mass here. Results are the same bits on every architecture: products never fuse into an FMA and the transcendental functions come from gomath.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OverdampedRoots ¶
OverdampedRoots are the two decay rates of an overdamped spring (zeta above 1), both negative, r1 the slower one that governs how long it takes to settle.
func SpringPosition ¶
SpringPosition is SpringStep's displacement alone, the same bits, for a caller that has no use for the velocity.
func SpringStep ¶
SpringStep is the damped harmonic oscillator's exact solution at angular frequency omega and damping ratio zeta: the displacement from the target and the velocity dt seconds after displacement x0 at velocity v0. A zeta of exactly 1 is the critically damped case, a negative one reads as 0, and a dt that is not positive returns the start unchanged.
Types ¶
type CubicBezier ¶
type CubicBezier struct {
// contains filtered or unexported fields
}
CubicBezier is a CSS cubic-bezier timing function, its control points reduced to polynomial coefficients. The zero value is not a curve; use NewCubicBezier. It is comparable.
func NewCubicBezier ¶
func NewCubicBezier(x1, y1, x2, y2 float64) CubicBezier
NewCubicBezier returns cubic-bezier(x1, y1, x2, y2). x1 and x2 clamp to [0, 1], the range CSS admits, so the curve stays a function of time; the y controls are free, and overshoot when they leave [0, 1].
func (CubicBezier) Ease ¶
func (b CubicBezier) Ease(x float64) float64
Ease is the progress at time x: exactly 0 at or before 0, exactly 1 at or after 1, and in between the curve's y where its x is x, the curve's parameter solved by Newton where it converges and bisection where it does not.