public static void AddFrameMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape initialShape, PowerPoint.Shape finalShape, float duration)
        {
            float initialX        = (initialShape.Left + (initialShape.Width) / 2);
            float initialY        = (initialShape.Top + (initialShape.Height) / 2);
            float initialRotation = initialShape.Rotation;
            float initialWidth    = initialShape.Width;
            float initialHeight   = initialShape.Height;
            float initialFont     = 0.0f;

            float finalX        = (finalShape.Left + (finalShape.Width) / 2);
            float finalY        = (finalShape.Top + (finalShape.Height) / 2);
            float finalRotation = finalShape.Rotation;
            float finalWidth    = finalShape.Width;
            float finalHeight   = finalShape.Height;
            float finalFont     = 0.0f;

            if (initialShape.HasTextFrame == Office.MsoTriState.msoTrue && (initialShape.TextFrame.HasText == Office.MsoTriState.msoTriStateMixed || initialShape.TextFrame.HasText == Office.MsoTriState.msoTrue) && initialShape.TextFrame.TextRange.Font.Size != finalShape.TextFrame.TextRange.Font.Size)
            {
                finalFont   = finalShape.TextFrame.TextRange.Font.Size;
                initialFont = initialShape.TextFrame.TextRange.Font.Size;
            }

            int numFrames = (int)(duration / 0.04f);

            numFrames = (numFrames > 30) ? 30 : numFrames;

            float incrementWidth    = ((finalWidth / initialWidth) - 1.0f) / numFrames;
            float incrementHeight   = ((finalHeight / initialHeight) - 1.0f) / numFrames;
            float incrementRotation = PowerPointLabsGlobals.GetMinimumRotation(initialRotation, finalRotation) / numFrames;
            float incrementLeft     = (finalX - initialX) / numFrames;
            float incrementTop      = (finalY - initialY) / numFrames;
            float incrementFont     = (finalFont - initialFont) / numFrames;

            AddFrameAnimationEffects(animationSlide, initialShape, incrementLeft, incrementTop, incrementWidth, incrementHeight, incrementRotation, incrementFont, duration, numFrames);
        }
 private static PowerPoint.Effect AddRotationAnimation(PowerPointSlide animationSlide, PowerPoint.Shape animationShape, float initialRotation, float finalRotation, float duration, ref PowerPoint.MsoAnimTriggerType trigger)
 {
     if (finalRotation != initialRotation)
     {
         PowerPoint.Effect            effectRotate = animationSlide.TimeLine.MainSequence.AddEffect(animationShape, PowerPoint.MsoAnimEffect.msoAnimEffectSpin, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, trigger);
         PowerPoint.AnimationBehavior rotate       = effectRotate.Behaviors[1];
         effectRotate.Timing.Duration         = duration;
         effectRotate.EffectParameters.Amount = PowerPointLabsGlobals.GetMinimumRotation(initialRotation, finalRotation);
         trigger = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
         return(effectRotate);
     }
     return(null);
 }