Code example for Interpolator

Methods: getInterpolation

0
                float x = timePassed * mDurationReciprocal;
 
                if (mInterpolator == null)
                    x = viscousFluid(x);
                else 
                    x = mInterpolator.getInterpolation(x);
 
                mCurrX = mStartX + Math.round(x * mDeltaX);
                mCurrY = mStartY + Math.round(x * mDeltaY);
                break; 
            case FLING_MODE:
                final float t = (float) timePassed / mDuration;
                final int index = (int) (NB_SAMPLES * t);
                final float tInf = (float) index / NB_SAMPLES;
                final float tSup = (float) (index + 1) / NB_SAMPLES;
                final float dInf = SPLINE[index];
                final float dSup = SPLINE[index + 1];
                final float distanceCoef = dInf + (t - tInf) / (tSup - tInf) * (dSup - dInf);
 
                mCurrX = mStartX + Math.round(distanceCoef * (mFinalX - mStartX));
                // Pin to mMinX <= mCurrX <= mMaxX