API 文档由 Go 源码生成,内容为英文。
type Curve func(progress float32) float32
Curve maps linear progress in [0, 1] onto eased progress. It is the timing of
one segment of a motion a component runs itself: a keyframed animation whose
segments are eased differently is not one Easing, so it asks Animate for
linear progress and evaluates its keyframes with curves like CubicBezier.
构造函数
CubicBezier#
func CubicBezier(x1, y1, x2, y2 float32) Curve
CubicBezier returns the CSS curve cubic-bezier(x1, y1, x2, y2), whose end
points are fixed at (0, 0) and (1, 1). x1 and x2 are clamped to [0, 1] so the
result stays a function of time; y is free, which is how a curve overshoots
or holds. Progress outside [0, 1] returns the exact end points.
Spring#
func Spring(bounce float32) Curve
Spring returns the step response of a spring, as a curve over the progress of
one segment: it overshoots 1 and settles back onto it. bounce runs from 0, a
critically damped settle with no overshoot at all, to 1, a wide wobble that
takes most of the segment to calm down. The curve reaches exactly 1 at
progress 1, so a finished motion paints the still glyph.
A spring is a function of the time a motion took rather than of the distance
it covered, so it belongs on the progress of one segment — the value a
keyframe segment eases from and to — which is what Curve is for.