Working with Animations in PowerPoint Library
28 Jul 202624 minutes to read
Animations are visual effects for the objects in PowerPoint presentation and animation helps to make a PowerPoint presentation more dynamic. Animation effects can be grouped into four categories:
- Entrance
- Emphasis
- Exit
- Motion paths
Entrance effects can be set to enter the objects with animations during slide show. Emphasis effects animate the objects on the spot. Exit effects allow objects to leave the slide show with animations. Motion Paths allow objects to move around the slide show. Each effect contains variables such as start (On click, with previous and after previous), delay, speed, repeat, and trigger. This makes animations more flexible and interactive.
The Syncfusion® Presentation library allows you to animate text, pictures, shapes, tables, SmartArt graphics, and charts in a PowerPoint presentation.
Adding animation effect to shapes
Animation effects can be added to shapes, images, tables, charts, and SmartArt diagrams. The following code example demonstrates how to add an animation effect to a shape.
//Create an instance for PowerPoint
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add bounce effect to the shape
IEffect bounceEffect = sequence.AddEffect(cubeShape, EffectType.Bounce, EffectSubtype.None, EffectTriggerType.OnClick);
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Sample.pptx");//Create an instance for PowerPoint
using (IPresentation pptxDoc = Presentation.Create())
{
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add bounce effect to the shape
IEffect bounceEffect = sequence.AddEffect(cubeShape, EffectType.Bounce, EffectSubtype.None, EffectTriggerType.OnClick);
//Save the Presentation
pptxDoc.Save("Sample.pptx");
}'Create an instance for PowerPoint
Using pptxDoc As IPresentation = Presentation.Create()
'Add a blank slide to Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Add normal shape to slide
Dim cubeShape As IShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300)
'Access the animation sequence to create effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Add bounce effect to the shape
Dim bounceEffect As IEffect = sequence.AddEffect(cubeShape, EffectType.Bounce, EffectSubtype.None, EffectTriggerType.OnClick)
'Save the Presentation
pptxDoc.Save("Sample.pptx")
End UsingYou can download a complete working sample from GitHub.
Adding interactive animation
Animations can be interactive when they depend on another slide element. For example, an animation associated with a rectangle is triggered when the user clicks an oval shape in the slide. The following code example demonstrates how to set an interactive animation.
//Create an instance for PowerPoint
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Add a shape to act as button
IShape buttonShape = slide.Shapes.AddShape(AutoShapeType.Oval, 100,100,50,50);
//Create the interactive sequence to make the animation effects interactive by triggering with button click
ISequence interactiveSequence = slide.Timeline.InteractiveSequences.Add(buttonShape);
//Add Fly effect with top subtype to animate the shape as fly from top
IEffect flyEffect = interactiveSequence.AddEffect(cubeShape, EffectType.Fly, EffectSubtype.Top, EffectTriggerType.OnClick);
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Sample.pptx");//Create an instance for PowerPoint
using (IPresentation pptxDoc = Presentation.Create())
{
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Add a shape to act as button
IShape buttonShape = slide.Shapes.AddShape(AutoShapeType.Oval, 100,100,50,50);
//Create the interactive sequence to make the animation effects interactive by triggering with button click
ISequence interactiveSequence = slide.Timeline.InteractiveSequences.Add(buttonShape);
//Add Fly effect with top subtype to animate the shape as fly from top
IEffect flyEffect = interactiveSequence.AddEffect(cubeShape, EffectType.Fly, EffectSubtype.Top, EffectTriggerType.OnClick);
//Save the Presentation
pptxDoc.Save("Sample.pptx");
}'Create an instance for PowerPoint
Using pptxDoc As IPresentation = Presentation.Create()
'Add a blank slide to Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Add normal shape to slide
Dim cubeShape As IShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300)
'Add a shape to act as button
Dim buttonShape As IShape = slide.Shapes.AddShape(AutoShapeType.Oval, 100, 100, 50, 50)
'Create the interactive sequence to make the animation effects interactive by triggering with button click
Dim interactiveSequence As ISequence = slide.Timeline.InteractiveSequences.Add(buttonShape)
'Add Fly effect with top subtype to animate the shape as fly from top
Dim flyEffect As IEffect = interactiveSequence.AddEffect(cubeShape, EffectType.Fly, EffectSubtype.Top, EffectTriggerType.OnClick)
'Save the Presentation
pptxDoc.Save("Sample.pptx")
End UsingYou can download a complete working sample from GitHub.
Adding animation to text
Animation effects can be applied to text. The following code example demonstrates how to set an animation effect to text.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add swivel effect with vertical subtype to the shape, build type is used to represent the animate level of the paragraph
IEffect swivelEffect = sequence.AddEffect(shape, EffectType.Swivel, EffectSubtype.Vertical, EffectTriggerType.OnClick, BuildType.ByLevelParagraphs1);
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Result.pptx");//Open an existing Presentation from file system
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add swivel effect with vertical subtype to the shape, build type is used to represent the animate level of the paragraph
IEffect swivelEffect = sequence.AddEffect(shape, EffectType.Swivel, EffectSubtype.Vertical, EffectTriggerType.OnClick, BuildType.ByLevelParagraphs1);
//Save the Presentation to the file system
pptxDoc.Save("Result.pptx");
}'Opens an existing Presentation from file system
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieve the first slide from Presentation
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieve the first shape
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation sequence to create effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Add swivel effect with vertical subtype to the shape, build type is used to represent the animate level of the paragraph
Dim swivelEffect As IEffect = sequence.AddEffect(shape, EffectType.Swivel, EffectSubtype.Vertical, EffectTriggerType.OnClick, BuildType.ByLevelParagraphs1)
'Save the Presentation to the file system
pptxDoc.Save("Result.pptx")
End UsingYou can download a complete working sample from GitHub.
Adding exit animation effect
When you add common animation effects for both entrance and exit types, animation is applied with the entrance effect by default. The following code example demonstrates how to set an exit type animation for a shape.
//Create an instance for PowerPoint
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add random bars effect to the shape
IEffect effect = sequence.AddEffect(cubeShape, EffectType.RandomBars, EffectSubtype.None, EffectTriggerType.OnClick);
//Change the preset class type of the effect from default entrance to exit
effect.PresetClassType = EffectPresetClassType.Exit;
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Sample.pptx");//Create an instance for PowerPoint
using (IPresentation pptxDoc = Presentation.Create())
{
//Add a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add random bars effect to the shape
IEffect effect = sequence.AddEffect(cubeShape, EffectType.RandomBars, EffectSubtype.None, EffectTriggerType.OnClick);
//Change the preset class type of the effect from default entrance to exit
effect.PresetClassType = EffectPresetClassType.Exit;
//Save the Presentation
pptxDoc.Save("Sample.pptx");
}'Create an instance for PowerPoint
Using pptxDoc As IPresentation = Presentation.Create()
'Add a blank slide to Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Add normal shape to slide
Dim cubeShape As IShape = slide.Shapes.AddShape(AutoShapeType.Cube, 50, 200, 300, 300)
'Access the animation sequence to create effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Add random bars effect to the shape
Dim effect As IEffect = sequence.AddEffect(cubeShape, EffectType.RandomBars, EffectSubtype.None, EffectTriggerType.OnClick)
'Change the preset class type of the effect from default entrance to exit
effect.PresetClassType = EffectPresetClassType.[Exit]
'Save the Presentation
pptxDoc.Save("Sample.pptx")
End UsingYou can download a complete working sample from GitHub.
Edit existing animation effect
The Presentation library allows you to edit the animations in existing presentations. The following example demonstrates how to modify an animation applied to a shape.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the animation effects of the particular shape
IEffect[] animationEffects = sequence.GetEffectsByShape(shape);
//Iterate the animation effect to make the change
IEffect animationEffect = animationEffects[0];
//Change the animation effect type to GrowAndTurn
animationEffect.Type = EffectType.GrowAndTurn;
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Animation.pptx");//Open an existing Presentation from file system
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the animation effects of the particular shape
IEffect[] animationEffects = sequence.GetEffectsByShape(shape);
//Iterate the animation effect to make the change
IEffect animationEffect = animationEffects[0];
//Change the animation effect type from swivel to GrowAndTurn
animationEffect.Type = EffectType.GrowAndTurn;
//Save the Presentation to the file system
pptxDoc.Save("Animation.pptx");
}'Open an existing Presentation from file system
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieve the first slide from Presentation
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieve the first shape.
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation main sequence to modify the effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Get the animation effects of the particular shape
Dim animationEffects As IEffect() = sequence.GetEffectsByShape(shape)
'Iterate the animation effect to make the change
Dim animationEffect As IEffect = animationEffects(0)
'Change the animation effect type from swivel to GrowAndTurn
animationEffect.Type = EffectType.GrowAndTurn
'Save the Presentation to the file system
pptxDoc.Save("Animation.pptx")
End UsingYou can download a complete working sample from GitHub.
Modifying animation effect sub type
The Presentation library allows you to edit the sub type of animation effects in existing presentations. The following example demonstrates how to modify a sub type applied to the existing animation.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the required animation effect from the slide
IEffect wheelEffect = sequence[0] as IEffect;
//Change the wheel animation effect sub type from 2 spoke to 4 spoke
wheelEffect.Subtype = EffectSubtype.Wheel4;
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Animation.pptx");//Opens an existing Presentation from file system
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieves the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieves the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the required animation effect from the slide
IEffect wheelEffect = sequence[0] as IEffect;
//Change the wheel animation effect sub type from 2 spoke to 4 spoke
wheelEffect.Subtype = EffectSubtype.Wheel4;
//Saves the Presentation to the file system
pptxDoc.Save("Result.pptx");
}'Opens an existing Presentation from file system
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieves the first slide from Presentation
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieves the first shape
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation main sequence to modify the effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Get the required animation effect from the slide
Dim wheelEffect As IEffect = TryCast(sequence(0), IEffect)
'Change the wheel animation effect sub type from 2 spoke to 4 spoke
wheelEffect.Subtype = EffectSubtype.Wheel4
'Saves the Presentation to the file system
pptxDoc.Save("Result.pptx")
End UsingYou can download a complete working sample from GitHub.
Modifying timing of animation effect
The Presentation library allows you to edit the animation timing in existing presentations. The following example demonstrates how to modify the existing animation timing applied to a shape.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the required animation effect from the slide
IEffect timingEffect = sequence[0] as IEffect;
//Increase the duration of the animation effect (value is in seconds)
timingEffect.Behaviors[0].Timing.Duration = 5;
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Animation.pptx");//Open an existing Presentation from file system
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieves the first slide from Presentation
ISlide slide = pptxDoc.Slides[0];
//Retrieves the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation main sequence to modify the effects
ISequence sequence = slide.Timeline.MainSequence;
//Get the required animation effect from the slide
IEffect timingEffect = sequence[0] as IEffect;
//Increase the duration of the animation effect (value is in seconds)
timingEffect.Behaviors[0].Timing.Duration = 5;
//Saves the Presentation to the file system
pptxDoc.Save("Result.pptx");
}'Open an existing Presentation from file system
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieves the first slide from Presentation
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieves the first shape
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation main sequence to modify the effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Get the required animation effect from the slide
Dim timingEffect As IEffect = TryCast(sequence(0), IEffect)
'Increase the duration of the animation effect (value is in seconds)
timingEffect.Behaviors(0).Timing.Duration = 5
'Save the Presentation to the file system.
pptxDoc.Save("Result.pptx")
End UsingYou can download a complete working sample from GitHub.
Reordering the animation effects
The Presentation library allows you to reorder the animation effects in existing presentations. The following example demonstrates how to change the order of animations applied to a shape.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the slide
ISlide slide = pptxDoc.Slides[0];
//Retrieve the shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence
ISequence sequence = slide.Timeline.MainSequence;
//Get the animation effects of the shape
IEffect[] shapeAnimationEffects = sequence.GetEffectsByShape(shape);
//Get the second animation effect of the shape
IEffect effect = shapeAnimationEffects[1];
//Remove the animation effect from the sequence
sequence.Remove(effect);
//Insert the removed animation effect as first
sequence.Insert(0, effect);
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Animation.pptx");//Open the existing presentation
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieve the slide
ISlide slide = pptxDoc.Slides[0];
//Retrieve the shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence
ISequence sequence = slide.Timeline.MainSequence;
//Get the animation effects of the shape
IEffect[] shapeAnimationEffects = sequence.GetEffectsByShape(shape);
//Get the second animation effect of the shape
IEffect effect = shapeAnimationEffects[1];
//Remove the animation effect from the sequence
sequence.Remove(effect);
//Insert the removed animation effect as first
sequence.Insert(0, effect);
//Save the created presentation
pptxDoc.Save("Output.pptx");
}'Open the existing presentation
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieve the slide
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieve the shape
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation sequence
Dim sequence As ISequence = slide.Timeline.MainSequence
'Get the animation effects of the shape
Dim shapeAnimationEffects As IEffect() = sequence.GetEffectsByShape(shape)
'Get the second animation effect of the shape
Dim effect As IEffect = shapeAnimationEffects(1)
'Remove the animation effect from the sequence
sequence.Remove(effect)
'Insert the removed animation effect as first
sequence.Insert(0, effect)
'Save the created presentation
pptxDoc.Save("Output.pptx")
End UsingYou can download a complete working sample from GitHub.
Creating custom path animation effect
The Presentation library allows you to create and modify custom animations in presentations. The following example demonstrates how to apply a custom animation to a shape.
//Creates an instance for PowerPoint
IPresentation pptxDoc = Presentation.Create();
//Adds a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Adds normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 200, 0, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add user path effect to the shape
IEffect pathEffect = sequence.AddEffect(cubeShape, EffectType.PathUser, EffectSubtype.None, EffectTriggerType.OnClick);
//Add commands to the empty path for moving
IMotionEffect motionBehavior = ((IMotionEffect)pathEffect.Behaviors[0]);
PointF[] points = new PointF[1];
//Add the move command to move the position of the shape
points[0] = new PointF(0, 0);
motionBehavior.Path.Add(MotionCommandPathType.MoveTo, points, MotionPathPointsType.Auto, false);
//Add the line command to move the shape in straight line
points[0] = new PointF(0, 0.25f);
motionBehavior.Path.Add(MotionCommandPathType.LineTo, points, MotionPathPointsType.Auto, false);
//Add the end command to finish the path animation
motionBehavior.Path.Add(MotionCommandPathType.End, null, MotionPathPointsType.Auto, false);
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Sample.pptx");//Creates an instance for PowerPoint
using (IPresentation pptxDoc = Presentation.Create())
{
//Adds a blank slide to Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Adds normal shape to slide
IShape cubeShape = slide.Shapes.AddShape(AutoShapeType.Cube, 200, 0, 300, 300);
//Access the animation sequence to create effects
ISequence sequence = slide.Timeline.MainSequence;
//Add user path effect to the shape
IEffect pathEffect = sequence.AddEffect(cubeShape, EffectType.PathUser, EffectSubtype.None, EffectTriggerType.OnClick);
//Add commands to the empty path for moving
IMotionEffect motionBehavior = ((IMotionEffect)pathEffect.Behaviors[0]);
PointF[] points = new PointF[1];
//Add the move command to move the position of the shape
points[0] = new PointF(0, 0);
motionBehavior.Path.Add(MotionCommandPathType.MoveTo, points, MotionPathPointsType.Auto, false);
//Add the line command to move the shape in straight line
points[0] = new PointF(0, 0.25f);
motionBehavior.Path.Add(MotionCommandPathType.LineTo, points, MotionPathPointsType.Auto, false);
//Add the end command to finish the path animation
motionBehavior.Path.Add(MotionCommandPathType.End, null, MotionPathPointsType.Auto, false);
//Saves the Presentation
pptxDoc.Save("Sample.pptx");
}'Creates an instance for PowerPoint
Using pptxDoc As IPresentation = Presentation.Create()
'Adds a blank slide to Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Adds normal shape to slide
Dim cubeShape As IShape = slide.Shapes.AddShape(AutoShapeType.Cube, 200, 0, 300, 300)
'Access the animation sequence to create effects
Dim sequence As ISequence = slide.Timeline.MainSequence
'Add user path effect to the shape
Dim pathEffect As IEffect = sequence.AddEffect(cubeShape, EffectType.PathUser, EffectSubtype.None, EffectTriggerType.OnClick)
'Add commands to the empty path for moving
Dim motionBehavior As IMotionEffect = DirectCast(pathEffect.Behaviors(0), IMotionEffect)
Dim points As PointF() = New PointF(0) {}
'Add the move command to move the position of the shape
points(0) = New PointF(0, 0)
motionBehavior.Path.Add(MotionCommandPathType.MoveTo, points, MotionPathPointsType.Auto, False)
'Add the line command to move the shape in straight line
points(0) = New PointF(0, 0.25F)
motionBehavior.Path.Add(MotionCommandPathType.LineTo, points, MotionPathPointsType.Auto, False)
'Add the end command to finish the path animation
motionBehavior.Path.Add(MotionCommandPathType.[End], Nothing, MotionPathPointsType.Auto, False)
'Saves the Presentation
pptxDoc.Save("Sample.pptx")
End UsingYou can download a complete working sample from GitHub.
Removing animation effect
The Presentation library allows you to remove the animation effects from a shape. The following example demonstrates how to remove an animation effect from a shape.
//Open an existing PowerPoint Presentation from the file system
IPresentation pptxDoc = Presentation.Open("Sample.pptx");
//Retrieve the slide
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence
ISequence sequence = slide.Timeline.MainSequence;
//Get the animation effects of the particular shape
IEffect[] animationEffects = sequence.GetEffectsByShape(shape);
//Remove the animation effects from the main sequence
foreach (IEffect effect in animationEffects)
{
sequence.Remove(effect);
}
//Save the PowerPoint Presentation to the file system
pptxDoc.Save("Animation.pptx");//Open the existing presentation
using (IPresentation pptxDoc = Presentation.Open("Sample.pptx"))
{
//Retrieve the slide
ISlide slide = pptxDoc.Slides[0];
//Retrieve the first shape
IShape shape = slide.Shapes[0] as IShape;
//Access the animation sequence
ISequence sequence = slide.Timeline.MainSequence;
//To Remove the animation effects from the shape
//Get the animation effects of the particular shape
IEffect[] animationEffects = sequence.GetEffectsByShape(shape);
//Remove the animation effect from the main sequence
foreach (IEffect effect in animationEffects)
{
sequence.Remove(effect);
}
//Save the created presentation
pptxDoc.Save("Result.pptx");
}'Open the existing presentation
Using pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
'Retrieve the slide
Dim slide As ISlide = pptxDoc.Slides(0)
'Retrieve the first shape
Dim shape As IShape = TryCast(slide.Shapes(0), IShape)
'Access the animation sequence
Dim sequence As ISequence = slide.Timeline.MainSequence
'To Remove the animation effects from the shape
'Get the animation effects of the particular shape
Dim animationEffects As IEffect() = sequence.GetEffectsByShape(shape)
'Remove the animation effect from the main sequence
For Each effect As IEffect In animationEffects
sequence.Remove(effect)
Next
'Save the created presentation
pptxDoc.Save("Result.pptx")
End UsingYou can download a complete working sample from GitHub.
Supported Animation Effect Types
Syncfusion® Presentation library supports the following predefined animation effects with the sub types like Microsoft PowerPoint.
|
Effects |
Entrance |
Exit |
Emphasis |
Motion Path |
Effect options |
| Appear | Yes | Yes | - | - | None |
| CurveUpDown | Yes | Yes | - | - | None |
| Ascend | Yes | Yes | - | - | None |
| Blast | - | - | Yes | - | None |
| Blinds | Yes | Yes | - | - |
|
| Blink | - | - | Yes | - | None |
| BoldFlash | - | - | Yes | - | None |
| BoldReveal | - | - | Yes | - | None |
| Boomerang | Yes | Yes | - | - | None |
| Bounce | Yes | Yes | - | - | None |
| Box | Yes | Yes | - | - |
|
| BrushOnColor | - | - | Yes | - | None |
| BrushOnUnderline | - | - | Yes | - | None |
| CenterRevolve | Yes | Yes | - | - | None |
| ChangeFillColor | - | - | Yes | - |
|
| ChangeFont | - | - | Yes | - |
|
| ChangeFontColor | - | - | Yes | - |
|
| ChangeFontSize | - | - | Yes | - |
|
| ChangeFontStyle | - | - | Yes | - |
|
| ChangeLineColor | - | - | Yes | - |
|
| Checkerboard | Yes | Yes | - | - |
|
| Circle | Yes | Yes | - | - |
|
| ColorBlend | - | - | Yes | - | None |
| ColorTypewriter | Yes | Yes | - | - | None |
| ColorWave | - | - | Yes | - | None |
| ComplementaryColor | - | - | Yes | - | None |
| ComplementaryColor2 | - | - | Yes | - | None |
| Compress | Yes | Yes | - | - | None |
| ContrastingColor | - | - | Yes | - | None |
| Crawl | Yes | Yes | - | - |
|
| Credits | Yes | Yes | - | - | None |
| Custom | - | - | - | - | - |
| Darken | - | - | Yes | - | None |
| Desaturate | - | - | Yes | - | None |
| Descend | Yes | Yes | - | - | None |
| Diamond | Yes | Yes | - | - |
|
| Dissolve | Yes | Yes | - | - | None |
| EaseInOut | Yes | Yes | - | - | None |
| Expand | Yes | Yes | - | - | None |
| Fade | Yes | Yes | - | - | None |
| FadedSwivel | Yes | Yes | - | - | None |
| FadedZoom | Yes | Yes | - | - |
|
| FlashBulb | - | - | Yes | - | None |
| FlashOnce | Yes | Yes | - | - | None |
| Flicker | - | - | Yes | - | None |
| Flip | Yes | Yes | - | - | None |
| Float | Yes | Yes | - | - | None |
| Fly | Yes | Yes | - | - |
|
| Fold | Yes | Yes | - | - | None |
| Glide | Yes | Yes | - | - | None |
| GrowAndTurn | Yes | Yes | - | - | None |
| GrowShrink | - | - | Yes | - | None |
| GrowWithColor | - | - | Yes | - | None |
| Lighten | - | - | Yes | - | None |
| LightSpeed | Yes | Yes | - | - | None |
| Path4PointStar | - | - | - | Yes | None |
| Path5PointStar | - | - | - | Yes | None |
| Path6PointStar | - | - | - | Yes | None |
| Path8PointStar | - | - | - | Yes | None |
| PathArcDown | - | - | - | Yes | None |
| PathArcLeft | - | - | - | Yes | None |
| PathArcRight | - | - | - | Yes | None |
| PathArcUp | - | - | - | Yes | None |
| PathBean | - | - | - | Yes | None |
| PathBounceLeft | - | - | - | Yes | None |
| PathBounceRight | - | - | - | Yes | None |
| PathBuzzsaw | - | - | - | Yes | None |
| PathCircle | - | - | - | Yes | None |
| PathCrescentMoon | - | - | - | Yes | None |
| PathCurvedSquare | - | - | - | Yes | None |
| PathCurvedX | - | - | - | Yes | None |
| PathCurvyLeft | - | - | - | Yes | None |
| PathCurvyRight | - | - | - | Yes | None |
| PathCurvyStar | - | - | - | Yes | None |
| PathDecayingWave | - | - | - | Yes | None |
| PathDiagonalDownRight | - | - | - | Yes | None |
| PathDiagonalUpRight | - | - | - | Yes | None |
| PathDiamond | - | - | - | Yes | None |
| PathDown | - | - | - | Yes | None |
| PathEqualTriangle | - | - | - | Yes | None |
| PathFigure8Four | - | - | - | Yes | None |
| PathFootball | - | - | - | Yes | None |
| PathFunnel | - | - | - | Yes | None |
| PathHeart | - | - | - | Yes | None |
| PathHeartbeat | - | - | - | Yes | None |
| PathHexagon | - | - | - | Yes | None |
| PathHorizontalFigure8 | - | - | - | Yes | None |
| PathInvertedSquare | - | - | - | Yes | None |
| PathInvertedTriangle | - | - | - | Yes | None |
| PathLeft | - | - | - | Yes | None |
| PathLoopdeLoop | - | - | - | Yes | None |
| PathNeutron | - | - | - | Yes | None |
| PathOctagon | - | - | - | Yes | None |
| PathParallelogram | - | - | - | Yes | None |
| PathPeanut | - | - | - | Yes | None |
| PathPentagon | - | - | - | Yes | None |
| PathPlus | - | - | - | Yes | None |
| PathPointyStar | - | - | - | Yes | None |
| PathRight | - | - | - | Yes | None |
| PathRightTriangle | - | - | - | Yes | None |
| PathSCurve1 | - | - | - | Yes | None |
| PathSCurve2 | - | - | - | Yes | None |
| PathSineWave | - | - | - | Yes | None |
| PathSpiralLeft | - | - | - | Yes | None |
| PathSpiralRight | - | - | - | Yes | None |
| PathSpring | - | - | - | Yes | None |
| PathSquare | - | - | - | Yes | None |
| PathStairsDown | - | - | - | Yes | None |
| PathSwoosh | - | - | - | Yes | None |
| PathTeardrop | - | - | - | Yes | None |
| PathTrapezoid | - | - | - | Yes | None |
| PathTurnDown | - | - | - | Yes | None |
| PathTurnRight | - | - | - | Yes | None |
| PathTurnUp | - | - | - | Yes | None |
| PathTurnUpRight | - | - | - | Yes | None |
| PathUp | - | - | - | Yes | None |
| PathUser | - | - | - | Yes | None |
| PathVerticalFigure8 | - | - | - | Yes | None |
| PathWave | - | - | - | Yes | None |
| PathZigzag | - | - | - | Yes | None |
| Peek | Yes | Yes | - | - |
|
| Pinwheel | Yes | Yes | - | - | None |
| Plus | Yes | Yes | - | - |
|
| RandomBars | Yes | Yes | - | - |
|
| RandomEffects | Yes | Yes | - | - | None |
| RiseUp | Yes | - | - | - | None |
| Shimmer | - | - | Yes | - | None |
| Sling | Yes | Yes | - | - | None |
| Spin | - | - | Yes | - | None |
| Spinner | - | - | Yes | - | None |
| Spiral | Yes | Yes | - | - | None |
| Split | Yes | Yes | - | - |
|
| Stretch | Yes | Yes | - | - |
|
| Strips | Yes | Yes | - | - |
|
| StyleEmphasis | - | - | Yes | - | None |
| Swish | Yes | Yes | - | - | None |
| Swivel | Yes | Yes | - | - |
|
| Teeter | - | - | Yes | - | None |
| Thread | - | - | Yes | - | None |
| Transparency | - | - | Yes | - | None |
| Unfold | Yes | Yes | - | - | None |
| VerticalGrow | - | - | Yes | - | None |
| Wave | - | - | Yes | - | None |
| Wedge | Yes | Yes | - | - | None |
| Wheel | Yes | Yes | - | - |
|
| Whip | yes | Yes | - | - | None |
| Wipe | Yes | Yes | - | - |
|
| Magnify | Yes | Yes | - | - | None |
| Zoom | Yes | Yes | - | - |
|
Online Demo
- Explore how to add different animation effects for shapes in a PowerPoint presentation using the .NET PowerPoint Library (Presentation) in a live demo here.
- See how to modify animation effects for shapes in a PowerPoint presentation using the .NET PowerPoint Library (Presentation) in a live demo here.