GTween class

GTween is a simple and flexible animation library for GraphX.

GTween can animate almost any object property. It uses easing equations to generate natural motion between two states of an object.

GTween is inspired by GreenSock's TweenLite/TweenMax library for JavaScript.

To create a new GTween animation, you need to provide a target object, duration of the animation, and a Map of properties to tween.

Example:

var myButton = SomeButton(); // create a button

// Tween its position over 2 seconds
myButton.tween(duration: 2.0, {'x': 100, 'y': 200});

Constructors

GTween(Object? target, double duration, Map? vars, [GVars? myVars])
Creates a new GTween instance with the specified target object, duration, and variables.

Properties

hashCode int
The hash code for this object.
no setterinherited
nanoVars GVars
Additional options and parameters for the tween, such as easing and delay.
getter/setter pair
ratio double?
The current ratio of the animation progress, from 0 to 1.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
target Object?
The object to be animated.
getter/setter pair
vars Map?
The properties and values to be tweened.
getter/setter pair

Methods

kill([Object? targets]) → void
Removes a tween or a list of tweens from the timeline.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaultEase EaseFunction
The default easing function to be used in tweens when an easing function is not specified.
getter/setter pair
initializedCommonWraps bool
Indicates whether common animatable wrappers have been registered. Once set to true, no further registration is allowed.
getter/setter pair
initializedEngine bool
Tracks whether the GTween engine has been initialized yet.
getter/setter pair
ticker EventSignal<double>
A signal that gets dispatched on every tick of the GTween engine.
getter/setter pair
timeScale double
The time scaling factor applied to all tweens.
getter/setter pair

Static Methods

delayedCall(double delay, Function callback, {Object? params, bool useFrames = false}) GTween
Similar to Future.delayed, yet GTween.delayedCall runs with the Ticker provider used by GTween, and also allows you to kill the delay in the target Function.
from(Object target, double duration, Map vars, [GVars? nanoVars]) GTween
Shortcut to start a tween on an target, start from the end values to the start values, this option basically flips the tweens.
hotReload() → void
Placeholder function for hot-reloading. Currently does nothing.
isTweening(Object target) bool
Returns whether the given target is currently being tweened. This method iterates through all active tweens and checks whether the target object matches the tween's target or animatable target.
killAll() → void
Kills all running tweens.
killTweensOf(Object? target) → void
Removes all tweens associated with the given target object.
processTick(double elapsed) → void
Processes a single tick of the GTween engine using the given elapsed time. Dispatches the ticker signal to update all registered GTween objects.
registerCommonWraps([List<GAnimatableBuilder>? otherWraps]) → void
Registers common wraps for GTweenable objects. This includes the GTweenableDisplayObject, GTweenableMap, GTweenableDouble, GTweenableInt, GTweenableMap, and GTweenableList classes. Additionally, other wraps can be provided via the otherWraps parameter.
registerWrap(GAnimatableBuilder builder) → void
Registers a new GTweenableBuilder with the engine.
to(Object? target, double duration, Map? vars, [GVars? nanoVars]) GTween
Creates a GTween that animates the properties of the target object from its current values to the values specified in the vars map over the specified duration. Is a shortcut to start a tween on target.