tween method
- required double duration,
- Object? x,
- Object? y,
- Object? scaleX,
- Object? scaleY,
- Object? scale,
- Object? rotation,
- Object? rotationX,
- Object? rotationY,
- Object? pivotX,
- Object? pivotY,
- Object? width,
- Object? height,
- Object? skewX,
- Object? skewY,
- Color? colorize,
- Object? alpha,
- EaseFunction? ease,
- double? delay,
- bool? useFrames,
- int overwrite = 1,
- Function? onStart,
- Object? onStartParams,
- Function? onComplete,
- Object? onCompleteParams,
- Function? onUpdate,
- Object? onUpdateParams,
- bool? runBackwards,
- bool? immediateRender,
- Map? startAt,
Creates a GTween animation for the given properties and returns it.
The duration
parameter specifies the length of the tween animation, and
the remaining parameters specify the properties to tween (in seconds
double
or frames int
).
The ease
parameter can be used to specify an easing function to use for
the tween animation. Use GEase
The delay
parameter can be used to delay the start of the tween
animation (in seconds double
or frames int
).
The useFrames
parameter can be set to true
to use frames instead of
seconds for the tween animation.
The overwrite
parameter specifies the mode of tweening when the GTween
animation already exists:
0 = no overwrite.
1 = overwrite all properties.
The onStart
, onStartParams
, onComplete
, onCompleteParams
,
onUpdate
, and onUpdateParams
parameters can be used to specify
functions to call at various stages of the tween animation.
The runBackwards
parameter can be set to true
to run the tween
animation backwards.
The startAt
parameter can be used to specify the initial values of the
tween animation properties.
Implementation
GTween tween({
required double duration,
Object? x,
Object? y,
Object? scaleX,
Object? scaleY,
Object? scale,
Object? rotation,
Object? rotationX,
Object? rotationY,
Object? pivotX,
Object? pivotY,
Object? width,
Object? height,
Object? skewX,
Object? skewY,
Color? colorize,
Object? alpha,
EaseFunction? ease,
double? delay,
bool? useFrames,
int overwrite = 1,
Function? onStart,
Object? onStartParams,
Function? onComplete,
Object? onCompleteParams,
Function? onUpdate,
Object? onUpdateParams,
bool? runBackwards,
bool? immediateRender,
Map? startAt,
}) {
final targetValues = {
if (x != null) 'x': x,
if (y != null) 'y': y,
if (scaleX != null) 'scaleX': scaleX,
if (scaleY != null) 'scaleY': scaleY,
if (scale != null) 'scale': scale,
if (rotation != null) 'rotation': rotation,
if (rotationX != null) 'rotationX': rotationX,
if (rotationY != null) 'rotationY': rotationY,
if (pivotX != null) 'pivotX': pivotX,
if (pivotY != null) 'pivotY': pivotY,
if (width != null) 'width': width,
if (height != null) 'height': height,
if (skewX != null) 'skewX': skewX,
if (skewY != null) 'skewY': skewY,
if (alpha != null) 'alpha': alpha,
if (colorize != null) 'colorize': colorize,
};
return GTween.to(
this,
duration,
targetValues,
GVars(
ease: ease,
delay: delay,
useFrames: useFrames,
overwrite: overwrite,
onStart: onStart,
onStartParams: onStartParams,
onComplete: onComplete,
onCompleteParams: onCompleteParams,
onUpdate: onUpdate,
onUpdateParams: onUpdateParams,
runBackwards: runBackwards,
immediateRender: immediateRender,
startAt: startAt,
),
);
}