2#include "animation/SInterpolatorImpl.h"
3#include "layout/SLayoutSize.h"
5#pragma warning(disable : 4985)
11static const float PI = 3.1415926f;
28 return (
float)pow((
double)input, mDoubleFactor);
34 , mDoubleFactor(2 * factor)
45 result = (float)(1.0f - (1.0f - input) * (1.0f - input));
49 result = (float)(1.0f - pow((1.0f - input), 2 * mFactor));
62 return (
float)(cos((input + 1) * PI) / 2.0f) + 0.5f;
69 return t * t * ((mTension + 1) * t - mTension);
90 return 0.5f * a(t * 2.0f, getTensionMulti());
92 return 0.5f * (o(t * 2.0f - 2.0f, getTensionMulti()) + 2.0f);
95float SAnticipateOvershootInterpolator::o(
float t,
float s)
97 return t * t * ((s + 1) * t + s);
100float SAnticipateOvershootInterpolator::a(
float t,
float s)
102 return t * t * ((s + 1) * t - s);
107 , mExtraTension(extraTension)
123 else if (t < 0.7408f)
124 return bounce(t - 0.54719f) + 0.7f;
125 else if (t < 0.9644f)
126 return bounce(t - 0.8526f) + 0.9f;
128 return bounce(t - 1.0435f) + 0.95f;
131float SBounceInterpolator::bounce(
float t)
139 return (
float)(sin(2 * mCycles * PI * input));
154 return t * t * ((mTension + 1) * t + mTension) + 1.0f;
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SAccelerateInterpolator(float factor=1.0f)
Constructor for SAccelerateInterpolator.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SAnticipateInterpolator()
Default constructor for SAnticipateInterpolator.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SAnticipateOvershootInterpolator(float tension=2.0f, float extraTension=1.5f)
Constructor for SAnticipateOvershootInterpolator.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SCycleInterpolator(float cycles=1.0f)
Constructor for SCycleInterpolator.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SDecelerateInterpolator(float factor=1.0f)
Constructor for SDecelerateInterpolator.
static bool fequal(float a, float b)
比较两个浮点数是否相等
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.
SOvershootInterpolator(float tension=2.0f)
Constructor for SOvershootInterpolator.
float getInterpolation(float input) SCONST OVERRIDE
Gets the interpolated value for the given input.