[GUI] How to use Motion and Animation to create visual effects

Widget library 2.x provides a class Animator that executes Animation.

The Animator can be used to synchronize the animation to reduce flushes.

The tick() method will be call at a fixed rate (50ms by default). Motions can be used to have non-linear visual effects. Widget library comes with some pre-set motions that can be visualized at easings.net.

Animation and motion can be used together to create smooth animation and visual effect. For example:

public class MyAnimation implements Animation {

	private Motion motion;

	public boolean tick(long currentTimeMillis) {
		if (motion == null) {
			motion = new QuadEaseInMotion(START_VALUE, END_VALUE, DURATION);
			// motion starts at creation by default (motion.start();)
		boolean finished = motion.isFinished();
		int value;
		if(finished) {
			value = motion.getStopValue();
		} else {
			value = motion.getCurrentValue();
		return !finished;