C# Class Nez.Tweens.Lerps

series of static methods to handle all common tween type structs along with unclamped lerps for them. unclamped lerps are required for bounce, elastic or other tweens that exceed the 0 - 1 range.
ファイルを表示 Open project: prime31/Nez Class Usage Examples

Public Methods

Method Description
angleLerp ( Vector2 from, Vector2 to, float t ) : Vector2
ease ( EaseType easeType, Microsoft.Xna.Framework.Color from, Microsoft.Xna.Framework.Color to, float t, float duration ) : Microsoft.Xna.Framework.Color
ease ( EaseType easeType, Microsoft.Xna.Framework.Quaternion from, Microsoft.Xna.Framework.Quaternion to, float t, float duration ) : Microsoft.Xna.Framework.Quaternion
ease ( EaseType easeType, Rectangle from, Rectangle to, float t, float duration ) : Rectangle
ease ( EaseType easeType, Vector2 from, Vector2 to, float t, float duration ) : Vector2
ease ( EaseType easeType, Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float t, float duration ) : Microsoft.Xna.Framework.Vector3
ease ( EaseType easeType, Vector4 from, Vector4 to, float t, float duration ) : Vector4
ease ( EaseType easeType, float from, float to, float t, float duration ) : float
easeAngle ( EaseType easeType, Vector2 from, Vector2 to, float t, float duration ) : Vector2
fastSpring ( Vector2 currentValue, Vector2 targetValue, Vector2 &velocity, float dampingRatio, float angularFrequency ) : Vector2

uses the semi-implicit euler method. slower, but always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/

fastSpring ( float currentValue, float targetValue, float &velocity, float dampingRatio, float angularFrequency ) : float

uses the semi-implicit euler method. faster, but not always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/

lerp ( Microsoft.Xna.Framework.Color from, Microsoft.Xna.Framework.Color to, float t ) : Microsoft.Xna.Framework.Color
lerp ( Rectangle from, Rectangle to, float t ) : Rectangle
lerp ( Vector2 from, Vector2 to, float t ) : Vector2
lerp ( Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float t ) : Microsoft.Xna.Framework.Vector3
lerp ( Vector4 from, Vector4 to, float t ) : Vector4
lerp ( float from, float to, float t ) : float
lerpDamp ( float source, float target, float smoothing ) : float

A smoothing rate of zero will give you back the target value (i.e. no smoothing), and a rate of 1 is technically not allowed, but will just give you back the source value (i.e. infinite smoothing). Note that this is the opposite of the way a lerp parameter works, but if you so desire, you can just use additive inverse of the smoothing parameter inside the Pow. Smoothing rate dictates the proportion of source remaining after one second

lerpTowards ( Vector2 from, Vector2 to, float remainingFactorPerSecond, float deltaTime ) : Vector2
lerpTowards ( Microsoft.Xna.Framework.Vector3 followerCurrentPosition, Microsoft.Xna.Framework.Vector3 targetPreviousPosition, Microsoft.Xna.Framework.Vector3 targetCurrentPosition, float smoothFactor, float deltaTime ) : Microsoft.Xna.Framework.Vector3
lerpTowards ( Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float remainingFactorPerSecond, float deltaTime ) : Microsoft.Xna.Framework.Vector3
lerpTowards ( float from, float to, float remainingFactorPerSecond, float deltaTime ) : float

remainingFactorPerSecond is the percentage of the distance it covers every second. should be between 0 and 1. if it's 0.25 it means it covers 75% of the remaining distance every second independent of the framerate

stableSpring ( Vector2 currentValue, Vector2 targetValue, Vector2 &velocity, float dampingRatio, float angularFrequency ) : Vector2

uses the implicit euler method. faster, but not always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/

stableSpring ( float currentValue, float targetValue, float &velocity, float dampingRatio, float angularFrequency ) : float

uses the implicit euler method. slower, but always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/

Method Details

angleLerp() public static method

public static angleLerp ( Vector2 from, Vector2 to, float t ) : Vector2
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
t float
return Microsoft.Xna.Framework.Vector2

ease() public static method

public static ease ( EaseType easeType, Microsoft.Xna.Framework.Color from, Microsoft.Xna.Framework.Color to, float t, float duration ) : Microsoft.Xna.Framework.Color
easeType EaseType
from Microsoft.Xna.Framework.Color
to Microsoft.Xna.Framework.Color
t float
duration float
return Microsoft.Xna.Framework.Color

ease() public static method

public static ease ( EaseType easeType, Microsoft.Xna.Framework.Quaternion from, Microsoft.Xna.Framework.Quaternion to, float t, float duration ) : Microsoft.Xna.Framework.Quaternion
easeType EaseType
from Microsoft.Xna.Framework.Quaternion
to Microsoft.Xna.Framework.Quaternion
t float
duration float
return Microsoft.Xna.Framework.Quaternion

ease() public static method

public static ease ( EaseType easeType, Rectangle from, Rectangle to, float t, float duration ) : Rectangle
easeType EaseType
from Microsoft.Xna.Framework.Rectangle
to Microsoft.Xna.Framework.Rectangle
t float
duration float
return Microsoft.Xna.Framework.Rectangle

ease() public static method

public static ease ( EaseType easeType, Vector2 from, Vector2 to, float t, float duration ) : Vector2
easeType EaseType
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
t float
duration float
return Microsoft.Xna.Framework.Vector2

ease() public static method

public static ease ( EaseType easeType, Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float t, float duration ) : Microsoft.Xna.Framework.Vector3
easeType EaseType
from Microsoft.Xna.Framework.Vector3
to Microsoft.Xna.Framework.Vector3
t float
duration float
return Microsoft.Xna.Framework.Vector3

ease() public static method

public static ease ( EaseType easeType, Vector4 from, Vector4 to, float t, float duration ) : Vector4
easeType EaseType
from Microsoft.Xna.Framework.Vector4
to Microsoft.Xna.Framework.Vector4
t float
duration float
return Microsoft.Xna.Framework.Vector4

ease() public static method

public static ease ( EaseType easeType, float from, float to, float t, float duration ) : float
easeType EaseType
from float
to float
t float
duration float
return float

easeAngle() public static method

public static easeAngle ( EaseType easeType, Vector2 from, Vector2 to, float t, float duration ) : Vector2
easeType EaseType
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
t float
duration float
return Microsoft.Xna.Framework.Vector2

fastSpring() public static method

uses the semi-implicit euler method. slower, but always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/
public static fastSpring ( Vector2 currentValue, Vector2 targetValue, Vector2 &velocity, float dampingRatio, float angularFrequency ) : Vector2
currentValue Microsoft.Xna.Framework.Vector2 Current value.
targetValue Microsoft.Xna.Framework.Vector2 Target value.
velocity Microsoft.Xna.Framework.Vector2 Velocity by reference. Be sure to reset it to 0 if changing the targetValue between calls
dampingRatio float lower values are less damped and higher values are more damped resulting in less springiness. /// should be between 0.01f, 1f to avoid unstable systems.
angularFrequency float An angular frequency of 2pi (radians per second) means the oscillation completes one /// full period over one second, i.e. 1Hz. should be less than 35 or so to remain stable
return Microsoft.Xna.Framework.Vector2

fastSpring() public static method

uses the semi-implicit euler method. faster, but not always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/
public static fastSpring ( float currentValue, float targetValue, float &velocity, float dampingRatio, float angularFrequency ) : float
currentValue float Current value.
targetValue float Target value.
velocity float Velocity by reference. Be sure to reset it to 0 if changing the targetValue between calls
dampingRatio float lower values are less damped and higher values are more damped resulting in less springiness. /// should be between 0.01f, 1f to avoid unstable systems.
angularFrequency float An angular frequency of 2pi (radians per second) means the oscillation completes one /// full period over one second, i.e. 1Hz. should be less than 35 or so to remain stable
return float

lerp() public static method

public static lerp ( Microsoft.Xna.Framework.Color from, Microsoft.Xna.Framework.Color to, float t ) : Microsoft.Xna.Framework.Color
from Microsoft.Xna.Framework.Color
to Microsoft.Xna.Framework.Color
t float
return Microsoft.Xna.Framework.Color

lerp() public static method

public static lerp ( Rectangle from, Rectangle to, float t ) : Rectangle
from Microsoft.Xna.Framework.Rectangle
to Microsoft.Xna.Framework.Rectangle
t float
return Microsoft.Xna.Framework.Rectangle

lerp() public static method

public static lerp ( Vector2 from, Vector2 to, float t ) : Vector2
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
t float
return Microsoft.Xna.Framework.Vector2

lerp() public static method

public static lerp ( Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float t ) : Microsoft.Xna.Framework.Vector3
from Microsoft.Xna.Framework.Vector3
to Microsoft.Xna.Framework.Vector3
t float
return Microsoft.Xna.Framework.Vector3

lerp() public static method

public static lerp ( Vector4 from, Vector4 to, float t ) : Vector4
from Microsoft.Xna.Framework.Vector4
to Microsoft.Xna.Framework.Vector4
t float
return Microsoft.Xna.Framework.Vector4

lerp() public static method

public static lerp ( float from, float to, float t ) : float
from float
to float
t float
return float

lerpDamp() public static method

A smoothing rate of zero will give you back the target value (i.e. no smoothing), and a rate of 1 is technically not allowed, but will just give you back the source value (i.e. infinite smoothing). Note that this is the opposite of the way a lerp parameter works, but if you so desire, you can just use additive inverse of the smoothing parameter inside the Pow. Smoothing rate dictates the proportion of source remaining after one second
public static lerpDamp ( float source, float target, float smoothing ) : float
source float Source.
target float Target.
smoothing float Smoothing.
return float

lerpTowards() public static method

public static lerpTowards ( Vector2 from, Vector2 to, float remainingFactorPerSecond, float deltaTime ) : Vector2
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
remainingFactorPerSecond float
deltaTime float
return Microsoft.Xna.Framework.Vector2

lerpTowards() public static method

public static lerpTowards ( Microsoft.Xna.Framework.Vector3 followerCurrentPosition, Microsoft.Xna.Framework.Vector3 targetPreviousPosition, Microsoft.Xna.Framework.Vector3 targetCurrentPosition, float smoothFactor, float deltaTime ) : Microsoft.Xna.Framework.Vector3
followerCurrentPosition Microsoft.Xna.Framework.Vector3
targetPreviousPosition Microsoft.Xna.Framework.Vector3
targetCurrentPosition Microsoft.Xna.Framework.Vector3
smoothFactor float
deltaTime float
return Microsoft.Xna.Framework.Vector3

lerpTowards() public static method

public static lerpTowards ( Microsoft.Xna.Framework.Vector3 from, Microsoft.Xna.Framework.Vector3 to, float remainingFactorPerSecond, float deltaTime ) : Microsoft.Xna.Framework.Vector3
from Microsoft.Xna.Framework.Vector3
to Microsoft.Xna.Framework.Vector3
remainingFactorPerSecond float
deltaTime float
return Microsoft.Xna.Framework.Vector3

lerpTowards() public static method

remainingFactorPerSecond is the percentage of the distance it covers every second. should be between 0 and 1. if it's 0.25 it means it covers 75% of the remaining distance every second independent of the framerate
public static lerpTowards ( float from, float to, float remainingFactorPerSecond, float deltaTime ) : float
from float From.
to float To.
remainingFactorPerSecond float Remaining factor per second.
deltaTime float Delta time.
return float

stableSpring() public static method

uses the implicit euler method. faster, but not always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/
public static stableSpring ( Vector2 currentValue, Vector2 targetValue, Vector2 &velocity, float dampingRatio, float angularFrequency ) : Vector2
currentValue Microsoft.Xna.Framework.Vector2 Current value.
targetValue Microsoft.Xna.Framework.Vector2 Target value.
velocity Microsoft.Xna.Framework.Vector2 Velocity by reference. Be sure to reset it to 0 if changing the targetValue between calls
dampingRatio float lower values are less damped and higher values are more damped resulting in less springiness. /// should be between 0.01f, 1f to avoid unstable systems.
angularFrequency float An angular frequency of 2pi (radians per second) means the oscillation completes one /// full period over one second, i.e. 1Hz. should be less than 35 or so to remain stable
return Microsoft.Xna.Framework.Vector2

stableSpring() public static method

uses the implicit euler method. slower, but always stable. see http://allenchou.net/2015/04/game-math-more-on-numeric-springing/
public static stableSpring ( float currentValue, float targetValue, float &velocity, float dampingRatio, float angularFrequency ) : float
currentValue float Current value.
targetValue float Target value.
velocity float Velocity by reference. Be sure to reset it to 0 if changing the targetValue between calls
dampingRatio float lower values are less damped and higher values are more damped resulting in less springiness. /// should be between 0.01f, 1f to avoid unstable systems.
angularFrequency float An angular frequency of 2pi (radians per second) means the oscillation completes one /// full period over one second, i.e. 1Hz. should be less than 35 or so to remain stable
return float