Skip to content

Easing

Overview

An Easing represents a function from the range [0,1] => [0,1] where f(0)=0 and f(1)=1. It is helpful for animation, to give a more 'natural' feeling.

Contains an implementation of generalized polynomial easing functions (where the 'in' version simply takes the input to a specific power, and other functions are generalized). These should be equivalent to the polynomial tweens that TWEEN.js uses, where t is The linear ratio [0,1] of the animation.

TODO #23 create unit tests

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class Easing

import { Easing } from 'scenerystack/twixt';

Constructor

new Easing( value : NumberFunction, derivative : NumberFunction, secondDerivative : NumberFunction )

Instance Methods

Static Methods

polynomialEaseInValue( n : number, t : number ) : number

The "polynomial ease in" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseOutValue( n : number, t : number ) : number

The "polynomial ease out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseInOutValue( n : number, t : number ) : number

The "polynomial ease in-out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseInDerivative( n : number, t : number ) : number

The derivative of the "polynomial ease in" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseOutDerivative( n : number, t : number ) : number

The derivative of the "polynomial ease out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseInOutDerivative( n : number, t : number ) : number

The derivative of the "polynomial ease in-out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseInSecondDerivative( n : number, t : number ) : number

The second derivative of the "polynomial ease in" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseOutSecondDerivative( n : number, t : number ) : number

The second derivative of the "polynomial ease out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseInOutSecondDerivative( n : number, t : number ) : number

The second derivative of the "polynomial ease in-out" function.

@param n - The degree of the polynomial (does not have to be an integer!) @param t - The linear ratio [0,1] of the animation

polynomialEaseIn( n : number ) : Easing

Creates a polynomial "in" easing (smooth start)

@param n - The degree of the polynomial (does not have to be an integer!)

polynomialEaseOut( n : number ) : Easing

Creates a polynomial "out" easing (smooth end)

@param n - The degree of the polynomial (does not have to be an integer!)

polynomialEaseInOut( n : number ) : Easing

Creates a polynomial "in-out" easing (smooth start and end)

@param n - The degree of the polynomial (does not have to be an integer!)

Static Properties

LINEAR

(readonly)

The identity easing

QUADRATIC_IN

(readonly)

Quadratic-derived easings (t^2)

QUADRATIC_OUT

(readonly)

QUADRATIC_IN_OUT

(readonly)

CUBIC_IN

(readonly)

Cubic-derived easings (t^3)

CUBIC_OUT

(readonly)

CUBIC_IN_OUT

(readonly)

QUARTIC_IN

(readonly)

Quartic-derived easings (t^4)

QUARTIC_OUT

(readonly)

QUARTIC_IN_OUT

(readonly)

QUINTIC_IN

(readonly)

Quintic-derived easings (t^5)

QUINTIC_OUT

(readonly)

QUINTIC_IN_OUT

(readonly)

Source Code

See the source for Easing.ts in the twixt repository.