Empeld
Empeld plugin documentation.
pluginbase.Objects.Tasks.Tween Class Reference

Helper class to create tweaning tasks that run over time More...

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)
 

Detailed Description

Helper class to create tweaning tasks that run over time

Member Function Documentation

◆ CreateTask()

static ITask pluginbase.Objects.Tasks.Tween.CreateTask ( float  fromVal,
float  toVal,
TimeSpan  length,
Action< float >  invoke,
Func< float, float, float, float >  integrator 
)
static
24  {
25  float f = 0f;
26  float step = 1f / ((float)length.TotalSeconds * STEPS);
27 
28  return new RecurringTask(() => {
29  f += step;
30  invoke(integrator(fromVal, toVal, f));
31  return f >= 1.0 ? TaskResult.Remove : TaskResult.Continue;
32  }, TimeSpan.FromMilliseconds(1000 / STEPS));
33  }
TaskResult
The result of a scheduled task
Definition: TaskResult.cs:8

◆ Linear()

static ITask pluginbase.Objects.Tasks.Tween.Linear ( float  fromVal,
float  toVal,
double  seconds,
Action< float >  invoke 
)
static
14  {
15  return CreateTask(fromVal, toVal, TimeSpan.FromSeconds(seconds), invoke, Interpolate.Linear);
16  }
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:23

◆ Smooth()

static ITask pluginbase.Objects.Tasks.Tween.Smooth ( float  fromVal,
float  toVal,
double  seconds,
Action< float >  invoke 
)
static
19  {
20  return CreateTask(fromVal, toVal, TimeSpan.FromSeconds(seconds), invoke, Interpolate.SmoothStep);
21  }
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:23

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