Documentation ¶
Overview ¶
Package gease implements spring based animation easings for gioui
Spring / force based animation of GUI components for gioui. In general plenty fast enough to always drive all dimensions through this package for smooth and nice animations at e.g. resizes etc.
Please see github.com/vron/gease/example as an example of the intended use-case.
Index ¶
Examples ¶
Constants ¶
const ( // DefaultOvershoot represents a resonable default for visualizations. DefaultOvershoot = 0.1 // DefaultPeriod represents a reasonable default for visualizations. DefaultPeriod = 750 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorEasing ¶
type ColorEasing struct {
// contains filtered or unexported fields
}
ColorEasing smoothly animates a color transition. It operates in LAB space with seperate alpha interpolation for a visually smooth transition.
func Color ¶
func Color(color color.RGBA) *ColorEasing
Color creates a new ColorEasing.
Example ¶
red, green := colornames.Red400, colornames.Green400 es := Color(red) es.Target(green) tt := time.Now() for !es.Step(tt) { // one would usually do: tt = time.Now() tt = tt.Add(time.Millisecond * 20) // use the color for drawing col := es.V() _ = col } // once the animation is converged we have the expected value fmt.Println(es.V() == green)
Output: true
func (*ColorEasing) Configure ¶
func (es *ColorEasing) Configure(period time.Duration) *ColorEasing
Configure sets the natural period of the animation. The provided period will thus roughly represent the time of a transition.
func (*ColorEasing) SetTime ¶
func (es *ColorEasing) SetTime(t time.Time)
SetTime stores the time t as the current time of the animation, without advancing the simulation. Usually there is no need to call SetTime since Color() internally set the initial time to time.Now().
func (*ColorEasing) Step ¶
func (es *ColorEasing) Step(t time.Time) (converged bool)
Step advances the simulation until t. If t is before any previos t Step was called with no work is done. If t.IsZero() time.Now() is assumed.
func (*ColorEasing) Target ¶
func (es *ColorEasing) Target(target color.RGBA)
Target sets the target color we should animate towards.
func (*ColorEasing) V ¶
func (es *ColorEasing) V() color.RGBA
V returns the current color of the easing.
type Easing ¶
type Easing interface { // SetTime is used to advance the easing in time Step(t time.Time) (converged bool) }
Easing is the interface an easing must satisfy to be used in a Hub.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
A Hub is a convenience wrapper for cases with constantly live easings.
func (*Hub) Remove ¶
Remove the easing from the hub, typically used such that it can be garbage collected if it will not be used further.
type PointEasing ¶
type PointEasing struct {
// contains filtered or unexported fields
}
PointEasing soothly animates a 2D-position.
func (*PointEasing) Configure ¶
func (es *PointEasing) Configure(overshoot float64, period time.Duration) *PointEasing
Configure sets the stiffness of the animation by specifing overshoot and period. The provided period will thus roughly represent the time of a transition abd overshoot the amount by which the animation should go past the target value before returning.
func (*PointEasing) SetTime ¶
func (es *PointEasing) SetTime(t time.Time)
SetTime stores the time t as the current time of the animation, without advancing the simulation. Usually there is no need to call SetTime since Color() internally set the initial time to time.Now().
func (*PointEasing) Step ¶
func (es *PointEasing) Step(t time.Time) (converged bool)
Step advances the simulation until t. If t is before any previos t Step was called with no work is done. If t.IsZero() time.Now() is assumed.
func (*PointEasing) Target ¶
func (es *PointEasing) Target(target f32.Point)
Target sets the target point we should animate to.
func (*PointEasing) V ¶
func (es *PointEasing) V() f32.Point
V returns the current point of the easing.
type UnitEasing ¶
type UnitEasing struct {
// contains filtered or unexported fields
}
UnitEasing soothly animates a gioui unit.Value. Note that the unit (e..g px, sp, dp) must be consistent in each UnitEasing.
func (*UnitEasing) Configure ¶
func (es *UnitEasing) Configure(overshoot float64, period time.Duration) *UnitEasing
Configure sets the stiffness of the animation by specifing overshoot and period. The provided period will thus roughly represent the time of a transition abd overshoot the amount by which the animation should go past the target value before returning.
func (*UnitEasing) SetTime ¶
func (es *UnitEasing) SetTime(t time.Time)
SetTime stores the time t as the current time of the animation, without advancing the simulation. Usually there is no need to call SetTime since Color() internally set the initial time to time.Now().
func (*UnitEasing) Step ¶
func (es *UnitEasing) Step(t time.Time) (converged bool)
Step advances the simulation until t. If t is before any previos t Step was called with the current value is returned without advancing the animation. If t.IsZero() time.Now() is assumed.
func (*UnitEasing) Target ¶
func (es *UnitEasing) Target(target unit.Value)
Target sets the target unit.Value we should animate to.
func (*UnitEasing) V ¶
func (es *UnitEasing) V() unit.Value
V returns the current value of the easing.