Package com.diozero.animation
Class Animation
java.lang.Object
com.diozero.animation.Animation
- All Implemented Interfaces:
Runnable
public class Animation extends Object implements Runnable
The Animation class constructs objects that represent a single Animation. An
Animation consists of a target and an array of segments. A target is the
device or list of devices that are being animated. A segment is a short
modular animation sequence (i.e. sit, stand, walk, etc). Segments are
synchronous and run first-in, first-out.
-
Constructor Summary
Constructors Constructor Description Animation(Collection<OutputDeviceInterface> targets, int fps, EasingFunction easing, float speed)
-
Method Summary
Modifier and Type Method Description void
enqueue(int durationMillis, float[] cuePoints, List<AnimationInstance.KeyFrame[]> keyFrames)
Add a segment to the animation's queue.void
enqueue(AnimationInstance animationInstance)
EasingFunction
getEasingFunction()
int
getFps()
boolean
getLoop()
int
getPeriodMs()
float
getSpeed()
Get the current speedCollection<OutputDeviceInterface>
getTargets()
Future<?>
play()
Play the animation.void
run()
void
setLoop(boolean loop)
void
stop()
Immediately stop the animation and flush the segment queue.
-
Constructor Details
-
Animation
public Animation(Collection<OutputDeviceInterface> targets, int fps, EasingFunction easing, float speed)
-
-
Method Details
-
getFps
public int getFps() -
getLoop
public boolean getLoop() -
setLoop
public void setLoop(boolean loop) -
play
Play the animation. Animation's are set to play by default and this only needs to be called if the animation has been paused or a segment's speed property was set to 0.- Returns:
- Future instance for the background animation thread
-
stop
public void stop()Immediately stop the animation and flush the segment queue. -
getSpeed
public float getSpeed()Get the current speed- Returns:
- current speed factor
-
getPeriodMs
public int getPeriodMs() -
getEasingFunction
-
getTargets
-
enqueue
public void enqueue(int durationMillis, float[] cuePoints, List<AnimationInstance.KeyFrame[]> keyFrames)Add a segment to the animation's queue.- Parameters:
durationMillis
- Time in milliseconds for the entire animationcuePoints
- List of relative time points at which to change to the next segmentkeyFrames
- List of segment values for target
-
enqueue
-
run
public void run()
-