Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EasingFunctions

Standard easing functions for motion in Excalibur, defined on a domain of [0, duration] and a range from [+startValue,+endValue] Given a time, the function will return a value from positive startValue to positive endValue.

function Linear (t) {
   return t * t;
}

// accelerating from zero velocity
function EaseInQuad (t) {
   return t * t;
}

// decelerating to zero velocity
function EaseOutQuad (t) {
   return t * (2 - t);
}

// acceleration until halfway, then deceleration
function EaseInOutQuad (t) {
   return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
}

// accelerating from zero velocity
function EaseInCubic (t) {
   return t * t * t;
}

// decelerating to zero velocity
function EaseOutCubic (t) {
   return (--t) * t * t + 1;
}

// acceleration until halfway, then deceleration
function EaseInOutCubic (t) {
   return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
}

Hierarchy

  • EasingFunctions

Index

Methods

Static EaseInCubic

  • EaseInCubic(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static EaseInOutCubic

  • EaseInOutCubic(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static EaseInOutQuad

  • EaseInOutQuad(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static EaseInQuad

  • EaseInQuad(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static EaseOutCubic

  • EaseOutCubic(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static EaseOutQuad

  • EaseOutQuad(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number

Static Linear

  • Linear(currentTime: number, startValue: number, endValue: number, duration: number): number
  • Parameters

    • currentTime: number
    • startValue: number
    • endValue: number
    • duration: number

    Returns number