VariableParabol

A simple and fast parametric easing function.

Its name comes from the fact that the plot of f(x) in [0..1] and with a control of 3 forms a regular parabolic curve.

Postblit

Copying this object is disabled.

A postblit is present on this object, but not explicitly documented in the source.

Members

Manifest constants

numControls
enum numControls;

Indicates that 1 control point is used.

Static functions

control
double control(double y)

Retrieves the control point coefficient.

controlClip
double controlClip(double c)

Clips the control point coefficient.

controlFx
double controlFx(double c)

Computes the Y coordinate of the control point.

fx
double fx(double x, double c)

Applies the standard transformation.

Static variables

ease
VariableParabol ease;

Uniform Easing API.

Examples

1 double x = 0;
2 double x0 = 120;
3 double x1 = 480;
4 double h = 200;
5 const int numPoints = 1000;
6 const double increment = 1.0 / numPoints;
7 
8 // draw a curve...
9 foreach(i; 0..numPoints)
10 {
11     double y = variableParabol.fx(x, 0.1);
12     // lineTo(x * (480 - 120) + 120, y * h);
13     x += increment;
14 }
15 import std.math: approxEqual;
16 assert(x.approxEqual(1.0));
17 
18 enum inc = 0.001;
19 double control = 0;
20 foreach(i; 0..1000)
21 {
22     auto cy = variableParabol.fx(0.5, control);
23     // Operation to get the control value as function of the cursor
24     assert(variableParabol.control(cy) == control);
25     control += 3 / 1000;
26 }
27 
28 assert(variableParabol.fx(0.0,3.0) == 0.0);
29 assert(variableParabol.fx(1.0,3.0) == 1.0);
30 assert(variableParabol.fx(0.0,2.0) == 0.0);
31 assert(variableParabol.fx(1.0,2.0) == 1.0);

Meta