ApplyEasing

From GECK
(Redirected from Ease)
Jump to: navigation, search


A function added by the ShowOff NVSE Plugin version 1.40.

Description

Applies an easing function to an input value (assumed to be between 0-1), to specify the rate of change of that input over time, and returns that eased value.

The easing function to use is specified via easingFuncName (which is NOT case-sensitive). Possible values are in Notes. easingMode is used to specify the mode of the easing function. Possible values:

0 = EaseIn
1 = EaseOut
2 = EaseInOut

Returns -1 if the operation was not successful (example: invalid easingFuncName string).

Syntax

[help]
(easedValue:float{0-1}) ApplyEasing input:float{0-1} easingFuncName:string easingMode:int{0,1,2} 

Or:

(easedValue:float{0-1}) Ease input:float{0-1} easingFuncName:string easingMode:int{0,1,2}

Example

float fCurrentTime
float fTotalLerpTime
float blendX
float fT
float oldx
float newX

fCurrentTime += GetSecondsPassed
if (fCurrentTime > fTotalLerpTime)
  fCurrentTime = fTotalLerpTime
endif
fT = fCurrentTime / fTotalLerpTime
fT = ApplyEasing fT "Sine" 0   ; Ease in
blendX = Lerp oldX newX fT

Example of using Lerp with this function to introduce a curve to the motion.

Notes

  • Visual examples of each easing function available here. The same code from that resource is used here.
  • Easing function names for easingFuncName:
Names (case-insensitive, only needs to match the start)
Sin
Cub
Quint
Circ
Elastic
Quad
Quart
Expo
Back
Bounce

See Also