示例#1
0
        public float GetValue(float t)
        {
            for (int i = 0; i < KeyPoints.Count; i++)
            {
                if (t >= KeyPoints.ElementAt(i).Key.X)
                {
                    float           x        = KeyPoints.ElementAt(i).Key.X;
                    float           y        = KeyPoints.ElementAt(i).Key.Y;
                    ITimingFunction function = KeyPoints.ElementAt(i).Value;

                    float intervalX = (i + 1 < KeyPoints.Count) ? KeyPoints.ElementAt(i + 1).Key.X - x : 1f - x;
                    float intervalY = (i + 1 < KeyPoints.Count) ? KeyPoints.ElementAt(i + 1).Key.Y - y : 1f - y;

                    return((function.GetValue((t - x) / intervalX) * intervalY) + y);
                }
            }
            return(1f);
        }