예제 #1
0
        /// <param name="normalizedTime">Should be float between 0f-1f.</param>
        private T GetValue(float normalizedTime)
        {
            const float fallbackEasingEndTime = 1f;
            var         easingLength          = _curve.GetEndTime(fallbackEasingEndTime);
            var         amount = _curve.Evaluate(normalizedTime * easingLength);

            return(_lerp(_startValue, _endValue, amount));
        }
        /// <summary>
        ///     Gets the gradient at the given time.
        /// </summary>
        /// <returns>The gradient.</returns>
        /// <param name="extends">Extends.</param>
        /// <param name="time">Time.</param>
        public static float GetGradient(this AnimationCurve extends, float time)
        {
            float end   = extends.GetEndTime();
            bool  isEnd = HydraMathUtils.Approximately(end, time);

            float firstTime  = isEnd ? time - CURVE_DELTA_FUDGE : time;
            float secondTime = isEnd ? time : time + CURVE_DELTA_FUDGE;

            // Cheat and check the value at time + some small amount
            float first  = extends.Evaluate(firstTime);
            float second = extends.Evaluate(secondTime);

            return((second - first) / CURVE_DELTA_FUDGE);
        }
 /// <param name="curve"></param>
 /// <param name="time">A value between 0.0f and 1.0f</param>
 public static float EvaluateAtNormalizedTime(this AnimationCurve curve, float time)
 {
     time = Mathf.Clamp01(time);
     return(curve.Evaluate(time * curve.GetEndTime()));
 }
 /// <summary>
 ///     Gets the length of the curve.
 /// </summary>
 /// <returns>The time length.</returns>
 /// <param name="extends">Extends.</param>
 public static float GetTimeLength(this AnimationCurve extends)
 {
     return(extends.GetEndTime() - extends.GetStartTime());
 }