Tween
Description
This class creates a basic tween, which automatically tracks a number from 0 to 1 over time. A Tweened number can be used within Processing to control an animation between two states. A Tween is given a time duration in seconds or frames, and optionally an easing function.
Example
import megamu.shapetween.*;

Tween ani;
void setup(){
  ani = new Tween(this, 2, Tween.SECONDS, Shaper.COSINE);
}

void draw(){
  background(255);
  ellipse(ani.time()*width, ani.position()*height, 4, 4);
}
Constructor
Tween( parent, duration )
Tween( parent, duration, durationType )
Tween( parent, duration, durationType, easing )
Parameters
parent
PApplet: typically use "this"
duration
float: tween duration in seconds unless you've set durationType to FRAMES
durationType
boolean: Tween.SECONDS or Tween.FRAMES (smoother)
easing
Shaper function used for animation easing. See setEasing() for details.
Methods
time()
Returns the current time
position()
Returns the current shaped position
isTweening()
Returns true if the tween is playing
start()
Begins a tween from 0
end()
Forces the end of the tween, setting time to 1
pause()
Haults playing
resume()
Resumes playing
reverse()
Causes the tween to reverse direction
seek()
Seeks to a specific time
setDuration()
Sets the duration of this tween
setEasing()
Sets the current easing shape function
setEasingMode()
Sets the current easing mode, such as ease in or ease out
noEasing()
Removes any easing shape function
setPlayMode()
Sets the play mode
repeat()
Causes the tween to repeat playing after it ends
noRepeat()
Turns off repeating for a tween
getEasing()
Returns the current easing shape function
playCount()
Returns the number of plays since start if set to repeat
speed()
Returns the relative speed of this Tween
force()
Returns the relative force of this Tween
tick()
Advances the tween one step, advanced use
Public Variables
timeScale
Modifys the speed at which all tweens move
Related
Shaper