Пример #1
0
        public static void GetTimelineTransform(TransformTimeline timeline, float position, DBTransform retult)
        {
            List <Frame> frameList = timeline.FrameList;
            int          i         = frameList.Count;

            TransformFrame currentFrame;
            float          tweenEasing;
            float          progress;
            TransformFrame nextFrame;

            while (i-- > 0)
            {
                currentFrame = frameList[i] as TransformFrame;
                if (currentFrame.Position <= position && currentFrame.Position + currentFrame.Duration > position)
                {
                    tweenEasing = currentFrame.TweenEasing;
                    if (i == frameList.Count - 1 || float.IsNaN(tweenEasing) || position == currentFrame.Position)
                    {
                        retult.Copy(currentFrame.Global);
                    }
                    else
                    {
                        progress = (position - currentFrame.Position) / currentFrame.Duration;
                        if (tweenEasing != 0 && !float.IsNaN(tweenEasing))
                        {
                            progress = TimelineState.GetEaseValue(progress, tweenEasing);
                        }

                        nextFrame = frameList[i + 1] as TransformFrame;

                        retult.X      = currentFrame.Global.X + (nextFrame.Global.X - currentFrame.Global.X) * progress;
                        retult.Y      = currentFrame.Global.Y + (nextFrame.Global.Y - currentFrame.Global.Y) * progress;
                        retult.SkewX  = TransformUtil.FormatRadian(currentFrame.Global.SkewX + (nextFrame.Global.SkewX - currentFrame.Global.SkewX) * progress);
                        retult.SkewY  = TransformUtil.FormatRadian(currentFrame.Global.SkewY + (nextFrame.Global.SkewY - currentFrame.Global.SkewY) * progress);
                        retult.ScaleX = currentFrame.Global.ScaleX + (nextFrame.Global.ScaleX - currentFrame.Global.ScaleX) * progress;
                        retult.ScaleY = currentFrame.Global.ScaleY + (nextFrame.Global.ScaleY - currentFrame.Global.ScaleY) * progress;
                    }
                    break;
                }
            }
        }