public class

Timings

extends Object
java.lang.Object
   ↳ sofia.graphics.Timings

Class Overview

This class provides static helper methods that provide friendlier names for timing functions (interpolators) used in animations. For example, one can write "Timings.easeInOut()" instead of "new AcceleratingDeceleratingInterpolator()". The former notation can be shorted even further by writing "import static sofia.graphics.Timings.*".

Summary

Public Constructors
Timings()
Public Methods
static AnticipateInterpolator backIn()

A timing function where the change starts backward and then flings forward.

static AnticipateInterpolator backIn(float tension)

A timing function where the change starts backward and then flings forward.

static AnticipateOvershootInterpolator backInOut()

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

static AnticipateOvershootInterpolator backInOut(float tension, float factor)

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

static AnticipateOvershootInterpolator backInOut(float tension)

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

static OvershootInterpolator backOut(float tension)

A timing function where the change flings forward, overshooting the end value, and then slowly settles back.

static OvershootInterpolator backOut()

A timing function where the change flings forward, overshooting the end value, and then slowly settles back.

static BounceInterpolator bounce()

A timing function that causes the animation to "bounce".

static CycleInterpolator cycle(float cycles)

A timing function that causes the animation to cycle forward and backward in a sinusoidal pattern.

static AccelerateInterpolator easeIn()

A timing function where the rate of change starts slowly and then speeds up until it ends.

static AccelerateInterpolator easeIn(float factor)

A timing function where the rate of change starts slowly and then speeds up until it ends, based on a specified factor.

static AccelerateDecelerateInterpolator easeInOut()

A timing function where the rate of change starts and ends slowly but speeds up through the middle.

static DecelerateInterpolator easeOut()

A timing function where the rate of change starts quickly and then slows down until it ends.

static DecelerateInterpolator easeOut(float factor)

A timing function where the rate of change starts quickly and then slows down until it ends, based on a specified factor.

static ElasticInInterpolator elasticIn()

A timing function that elastically snaps from the start value.

static ElasticInOutInterpolator elasticInOut()

A timing function that elastically snaps in from the start value and then snaps back again when it reaches the end value.

static ElasticOutInterpolator elasticOut()

A timing function that elastically snaps back when it reaches the end value.

static LinearInterpolator linear()

A timing function where the rate of change is constant.

[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Timings ()

Public Methods

public static AnticipateInterpolator backIn ()

A timing function where the change starts backward and then flings forward.

This timing function is represented by f(t) = t^2 * (3 * t - 2), where t is the current time in the animation normalized to the range [0.0, 1.0]. (In other words, it is equivalent to backIn(float) with a tension of 2.0.)

This timing function corresponds to AnticipateInterpolator.

Returns
  • a timing function that starts backward and then flings forward

public static AnticipateInterpolator backIn (float tension)

A timing function where the change starts backward and then flings forward.

This timing function is represented by f(t) = t^2 * ((tension + 1) * t - tension), where t is the current time in the animation normalized to the range [0.0, 1.0]. Higher values of tension cause the animation to "pull backward" more and then accelerate faster when "snapped"; a tension value of 0 makes it identical to easeIn().

This timing function corresponds to AnticipateInterpolator.

Parameters
tension the amount of tension to apply to the animation before it is "let go"
Returns
  • a timing function that starts backward and then flings forward

public static AnticipateOvershootInterpolator backInOut ()

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

This timing function is represented by TODO, where t is the current time in the animation normalized to the range [0.0, 1.0]. (In other words, it is equivalent to backInOut(float) with a tension of 2.0.)

This timing function corresponds to AnticipateOvershootInterpolator.

Returns
  • a timing function that starts backward, flings forward past the end point and then settles back to the end

public static AnticipateOvershootInterpolator backInOut (float tension, float factor)

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

This timing function is represented by TODO, where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to AnticipateOvershootInterpolator.

Parameters
tension the amount of tension to apply to the animation before it is "let go"
factor the amount by which to multiply the tension
Returns
  • a timing function that flings forward past the end point and then settles back to the end

public static AnticipateOvershootInterpolator backInOut (float tension)

A timing function where the change starts backward, then flings forward, overshooting the end value, and then slowly settles back.

This timing function is represented by TODO, where t is the current time in the animation normalized to the range [0.0, 1.0]. (In other words, it is equivalent to backInOut(float) with a tension of 2.0.)

This timing function corresponds to AnticipateOvershootInterpolator.

Parameters
tension the amount of tension to apply to the animation before it is "let go"
Returns
  • a timing function that flings forward past the end point and then settles back to the end

public static OvershootInterpolator backOut (float tension)

A timing function where the change flings forward, overshooting the end value, and then slowly settles back.

This timing function is represented by f(t) = (t - 1)^2 * ((tension + 1)(t - 1) + tension) + 1, where t is the current time in the animation normalized to the range [0.0, 1.0]. (In other words, it is equivalent to backOut(float) with a tension of 2.0.)

This timing function corresponds to OvershootInterpolator.

Parameters
tension the amount of tension to apply to the animation before it is "let go"
Returns
  • a timing function that flings forward past the end point and then settles back to the end

public static OvershootInterpolator backOut ()

A timing function where the change flings forward, overshooting the end value, and then slowly settles back.

This timing function is represented by f(t) = (t - 1)^2 * ((tension + 1)(t - 1) + tension) + 1, where t is the current time in the animation normalized to the range [0.0, 1.0]. (In other words, it is equivalent to backOut(float) with a tension of 2.0.)

This timing function corresponds to OvershootInterpolator.

Returns
  • a timing function that flings forward past the end point and then settles back to the end

public static BounceInterpolator bounce ()

A timing function that causes the animation to "bounce".

This timing function is represented by a piecewise function:

 f(t) = 8 * (1.1226 * t)^2,                  if      0 <= t < 0.3535
      = 8 * (1.1226 * t - 0.54719)^2 + 0.7,  if 0.3535 <= t < 0.7408,
      = 8 * (1.1226 * t - 0.8526)^2 + 0.9,   if 0.7408 <= t < 0.9644,
      = 8 * (1.1226 * t - 1.0435)^2 + 0.95,  if 0.9644 <= t <= 1,
where t is the current time in the animation normalized to the range [0.0, 1.0].

To elaborate, an animation that uses this timing function will ease in (accelerate) from start to end in about 31% of its duration, then "bounce" (accelerating backward and then decelerating forward) to the 66% point in its duration, bounce again with less strength to the 86% point, and then bounce one more time until the end of the duration, with each bounce occurring at less strength than the one before.

This timing function corresponds to BounceInterpolator.

Returns
  • a timing function that causes the animation to bounce

public static CycleInterpolator cycle (float cycles)

A timing function that causes the animation to cycle forward and backward in a sinusoidal pattern.

This timing function is represented by f(t) = sin(2 * cycles * pi) where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to CycleInterpolator.

Parameters
cycles the number of cycles to run the animation
Returns
  • a timing function that causes the animation to cycle

public static AccelerateInterpolator easeIn ()

A timing function where the rate of change starts slowly and then speeds up until it ends.

This timing function is represented by f(t) = t^2, where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to AccelerateInterpolator.

Returns
  • a timing function that eases in an accelerating animation

public static AccelerateInterpolator easeIn (float factor)

A timing function where the rate of change starts slowly and then speeds up until it ends, based on a specified factor.

This timing function is represented by f(t) = t^(2 * factor), where t is the current time in the animation normalized to the range [0.0, 1.0]. A factor of 1.0 produces the same result as easeIn(); larger values exaggerate the effect (the animation eases in more slowly but ends much faster).

This timing function corresponds to AccelerateInterpolator.

Parameters
factor the factor by which to exaggerate the animation
Returns
  • a timing function that eases in an accelerating animation

public static AccelerateDecelerateInterpolator easeInOut ()

A timing function where the rate of change starts and ends slowly but speeds up through the middle. This is the default timing function for any animation that does not specify an alternative.

This timing function is represented by f(t) = 0.5 + cos((1 + t) * pi) / 2, where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to AccelerateDecelerateInterpolator.

Returns
  • a timing function that eases in and eases out an animation

public static DecelerateInterpolator easeOut ()

A timing function where the rate of change starts quickly and then slows down until it ends.

This timing function is represented by f(t) = 1 - (1 - t)^2, where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to DecelerateInterpolator.

Returns
  • a timing function that eases out a decelerating animation

public static DecelerateInterpolator easeOut (float factor)

A timing function where the rate of change starts quickly and then slows down until it ends, based on a specified factor.

This timing function is represented by f(t) = 1 - (1 - t)^(2 * factor), where t is the current time in the animation normalized to the range [0.0, 1.0]. A factor of 1.0 produces the same result as easeOut(); larger values exaggerate the effect (the animation starts more quickly but eases out much more slowly).

This timing function corresponds to DecelerateInterpolator.

Parameters
factor the factor by which to exaggerate the animation
Returns
  • a timing function that eases out a decelerating animation

public static ElasticInInterpolator elasticIn ()

A timing function that elastically snaps from the start value.

This timing function is represented by TODO where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to ElasticInInterpolator (which is a custom interpolator provided by Sofia, not one built into the Android API).

Returns
  • a timing function that causes the animation to snap in

public static ElasticInOutInterpolator elasticInOut ()

A timing function that elastically snaps in from the start value and then snaps back again when it reaches the end value.

This timing function is represented by TODO where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to ElasticInOutInterpolator (which is a custom interpolator provided by Sofia, not one built into the Android API).

Returns
  • a timing function that causes the animation to snap at the beginning and end

public static ElasticOutInterpolator elasticOut ()

A timing function that elastically snaps back when it reaches the end value.

This timing function is represented by TODO where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to ElasticOutInterpolator (which is a custom interpolator provided by Sofia, not one built into the Android API).

Returns
  • a timing function that causes the animation to snap back

public static LinearInterpolator linear ()

A timing function where the rate of change is constant.

This timing function is represented by f(t) = t, where t is the current time in the animation normalized to the range [0.0, 1.0].

This timing function corresponds to LinearInterpolator.

Returns
  • a timing function that is constant