Open Source Cross-Platform Game Programming

Easing

Provides easing functions for various predefined equations and customizable functions as well.

class EasingFunction[link]

Embodies an easing equation.

Fields

NameTypeDescription
.LINEAR Easing.EasingFunction

An easing function that follows a linear progression. Defined by the function f(t) = t for t = 0 to 1.

.QUADRATIC Easing.EasingFunction

An easing function that follows a quadratic progression. Defined by the function f(t) = t^2 for t = 0 to 1.

.CUBIC Easing.EasingFunction

An easing function that follows a cubic progression. Defined by the function f(t) = t^3 for t = 0 to 1.

.QUART Easing.EasingFunction

An easing function that follows a quartic progression. Defined by the function f(t) = t^4 for t = 0 to 1.

.QUINT Easing.EasingFunction

An easing function that follows a quintic progression. Defined by the function f(t) = t^5 for t = 0 to 1.

.CIRCLE Easing.EasingFunction

An easing function that follows a circular progression. Defined by the function f(t) = sqrt(1 - t^2) for t = 0 to 1.

.SIN Easing.EasingFunction

An easing function that follows the shape of a sine curve. Defined by the function f(t) = 1 - cos(t * pi / 2) for t = 0 to 1.

.ELASTIC Easing.EasingFunction

An easing function that follows an elastic behavior. Defined by a complicated function that can be seen in the source code.

new EasingFunction(functionPointer, intervals)[link]

Creates a new EasingFunction instance based on a custom equation. The function is sampled at even intervals to create a lookup table for optimal speed. This allows for fast run-time computations of easing for potentially complex equations.

Arguments

NameTypeOptionalDescription
functionPointer function

A function that takes in a float value from 0 to 1 and returns a value typically in the range of 0 to 1, although it can go out of that range e.g. to achieve springiness.

intervals integer Optional

The number of intervals to sample the given function. Default value is 100.

function ease(start, end, current, duration, useIntegers)[link]

Interpolates the value by using a compound function of the easeOut and easeIn functions.

Arguments

NameTypeOptionalDescription
start float

A starting value

end float

An ending value

current float

The current point in time

duration float

The length of the interpolation timeline

useIntegers boolean Optional

If true, the output will be rounded to the closest integer. Default value is false.

function easeIn(start, end, current, duration, useIntegers)[link]

Interpolate two values by evaluating the easing function from 0 to 1

Arguments

NameTypeOptionalDescription
start float

A starting value

end float

An ending value

current float

The current point in time

duration float

The length of the interpolation timeline

useIntegers boolean Optional

If true, the output will be rounded to the closest integer. Default value is false.

function easeOut(start, end, current, duration, useIntegers)[link]

Interpolate two values by evaluating the easing function backwards from 1 to 0 and then transposing the output by subtracting it from 1.

Arguments

NameTypeOptionalDescription
start float

A starting value

end float

An ending value

current float

The current point in time

duration float

The length of the interpolation timeline

useIntegers boolean Optional

If true, the output will be rounded to the closest integer. Default value is false.