animation

package
v0.1.112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 Imported by: 0

README

Animation

This package provides a set of animation utilities for GoCompose.

Animation tracking

  • target duration
  • start time
  • now

Animation with momentum (Future)

  • initial velocity
  • acceleration and deceleration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation added in v0.1.89

type Animation struct {
	// contains filtered or unexported fields
}

Animation holds state for an Animation between two states that is not invertible.

func NewAnimation added in v0.1.89

func NewAnimation(duration time.Duration) Animation

func (*Animation) Animating added in v0.1.89

func (n *Animation) Animating(gtx layout.Context) bool

func (*Animation) Duration added in v0.1.89

func (n *Animation) Duration() time.Duration

func (*Animation) Progress added in v0.1.89

func (n *Animation) Progress(gtx layout.Context) float32

Progress returns the current progress through the animation as a value in the range [0,1]

func (*Animation) SetDuration added in v0.1.89

func (n *Animation) SetDuration(d time.Duration)

func (*Animation) Start added in v0.1.89

func (n *Animation) Start(now time.Time)

func (*Animation) StartTime added in v0.1.89

func (n *Animation) StartTime() time.Time

type VisibilityAnimation

type VisibilityAnimation struct {
	// How long does the animation last
	State     VisibilityAnimationState
	Animation Animation
}

VisibilityAnimation holds the animation state for animations that transition between a "visible" and "invisible" state for a fixed duration of time.

func NewVisibilityAnimation added in v0.1.89

func NewVisibilityAnimation(duration time.Duration, visibilityState VisibilityAnimationState) *VisibilityAnimation

func (VisibilityAnimation) Animating

func (v VisibilityAnimation) Animating() bool

Animating() returns whether the animation is either in the process of appearsing or disappearing.

func (*VisibilityAnimation) Appear

func (v *VisibilityAnimation) Appear(now time.Time)

Appear triggers the animation to begin becoming visible at the provided time. It is a no-op if the animation is already visible.

func (*VisibilityAnimation) Disappear

func (v *VisibilityAnimation) Disappear(now time.Time)

Disappear triggers the animation to begin becoming invisible at the provided time. It is a no-op if the animation is already invisible.

func (*VisibilityAnimation) Revealed

func (v *VisibilityAnimation) Revealed(gtx layout.Context) float32

Revealed returns the fraction of the animated entity that should be revealed at the current time in the animation. This fraction is computed with linear interpolation.

Revealed should be invoked during every frame that v.Animating() returns true.

If the animation reaches its end this frame, Revealed will transition it to a non-animating state automatically.

If the animation is in the process of animating, calling Revealed will automatically add an InvalidateOp to the provided layout.Context to ensure that the next frame will be generated promptly.

func (*VisibilityAnimation) String

func (v *VisibilityAnimation) String(gtx layout.Context) string

func (*VisibilityAnimation) ToggleVisibility

func (v *VisibilityAnimation) ToggleVisibility(now time.Time)

ToggleVisibility will make an invisible animation begin the process of becoming visible and a visible animation begin the process of disappearing.

func (VisibilityAnimation) Visible

func (v VisibilityAnimation) Visible() bool

Visible() returns whether any part of the animated entity should be visible during the current animation frame.

type VisibilityAnimationState

type VisibilityAnimationState int

VisibilityAnimationState represents possible states that a VisibilityAnimation can be in.

const (
	Visible VisibilityAnimationState = iota
	Disappearing
	Appearing
	Invisible
)

func (VisibilityAnimationState) String

func (v VisibilityAnimationState) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL