Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.Tasks.Tween Class Reference

Static Public Member Functions

static ITask Linear (float fromVal, float toVal, double seconds, Action< float > invoke)
 
static ITask Smooth (float fromVal, float toVal, double seconds, Action< float > invoke)
 
static ITask CreateTask (float fromVal, float toVal, TimeSpan length, Action< float > invoke, Func< float, float, float, float > integrator)
 

Member Function Documentation

static ITask pluginbase.Objects.Tasks.Tween.CreateTask ( float  fromVal,
float  toVal,
TimeSpan  length,
Action< float >  invoke,
Func< float, float, float, float >  integrator 
)
static
21  {
22  float f = 0f;
23  float step = 1f / ((float)length.TotalSeconds * STEPS);
24 
25  return new RecurringTask(() => {
26  f += step;
27  invoke(integrator(fromVal, toVal, f));
28  return f >= 1.0 ? TaskResult.Remove : TaskResult.Continue;
29  }, TimeSpan.FromMilliseconds(1000 / STEPS));
30  }
TaskResult
The result of a scheduled task
Definition: TaskResult.cs:8
static ITask pluginbase.Objects.Tasks.Tween.Linear ( float  fromVal,
float  toVal,
double  seconds,
Action< float >  invoke 
)
static
11  {
12  return CreateTask(fromVal, toVal, TimeSpan.FromSeconds(seconds), invoke, Interpolate.Linear);
13  }
static float Linear(float a, float b, float u)
Linearly interpolate two numbers by a 0-1 range
Definition: Interpolate.cs:16
Helper methods for interpolation
Definition: Interpolate.cs:8
static ITask CreateTask(float fromVal, float toVal, TimeSpan length, Action< float > invoke, Func< float, float, float, float > integrator)
Definition: Tween.cs:20
static ITask pluginbase.Objects.Tasks.Tween.Smooth ( float  fromVal,
float  toVal,
double  seconds,
Action< float >  invoke 
)
static
16  {
17  return CreateTask(fromVal, toVal, TimeSpan.FromSeconds(seconds), invoke, Interpolate.SmoothStep);
18  }
static float SmoothStep(float a, float b, float u)
Smooth interpolation, similar to cosine, but much faster
Definition: Interpolate.cs:63
Helper methods for interpolation
Definition: Interpolate.cs:8
static ITask CreateTask(float fromVal, float toVal, TimeSpan length, Action< float > invoke, Func< float, float, float, float > integrator)
Definition: Tween.cs:20

The documentation for this class was generated from the following file: