Applying Animations on Shapes

Skip to end of metadata
Go to start of metadata
Animation is one of the most important parts of the presentations that make them more attractive and meaningful. Aspose.Slides for .NET also allows developers to apply different kinds of animation effects on different kinds of shapes. There are more than 60 pre-defined animation effects provided by Aspose.Slides for .NET. In this topic, we will show how to apply animation effects on shapes and also control their animation order.

Applying Animation Effects

To apply an animation effect on any shape in the slide, please follow the steps below:

  • Create an instance of Presentation class
  • Obtain the reference of a slide by using its Position
  • Add a Shape to the slide
  • Apply a desired Animation Effect on the shape from the list of pre-defined effects. More than 60 animation effects are pre-defined in Aspose.Slides for .NET
  • Write the modified presentation as a PPT file

In the example given below, we have added a rectangle shape to the slide with the Spiral effect applied on it.

Example

[C#]
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation("demo.ppt");


//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition(2);


//Adding a rectangle shape into the slide by defining its X,Y postion, width
//and height
Shape shape = slide.Shapes.AddRectangle(1400, 1100, 3000, 2000);


//Applying an animation effect on the rectangle shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral;


//Writing the presentation as a PPT file
pres.Write("C:\\modified.ppt");

 
[Visual Basic]
'Instantiate a Presentation object that represents a PPT file
Dim pres As Presentation = New Presentation("demo.ppt")


'Accessing a slide using its slide position
Dim slide As Slide = pres.GetSlideByPosition(2)


'Adding a rectangle shape into the slide by defining its X,Y postion, width
'and height
Dim shape As Shape = slide.Shapes.AddRectangle(1400, 1100, 3000, 2000)


'Applying an animation effect on the rectangle shape
shape.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral


'Writing the presentation as a PPT file
pres.Write("C:\\modified.ppt")

 

Figure : Spiral animation effect applied on a rectangle

Controlling Animation Order

The above section describes about applying animation effect on a single shape. But, if you want to add more than one shapes and also want to apply animation effects on these shapes, you may want to change the animation order of the shapes added to the slide. For example, in the normal scenario, if you add two shapes:Shape A and Shape B, first Shape A will animate and then Shape B. But, if you want to specify that Shape A should animate after Shape B, you can change their animation order.

To control the animation order of desired shapes in the slide, please follow the steps below:

  • Create an instance of Presentation class
  • Obtain the reference of a slide by using its Position
  • Add multiple Shapes to the slide
  • Apply desired Animation Effects on these shapes
  • Set the Animation Order of these shapes
  • Write the modified presentation as a PPT file

In the example given below, we have added rectangle and ellipse shapes to the slide. Further, we have changed their animation order after applying animation effects on both shapes.

Example

[C#]
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation("demo.ppt");


//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition(2);


//Adding two shapes to the slide
Shape shape1 = slide.Shapes.AddRectangle(1400, 1100, 3000, 2000);
Shape shape2 = slide.Shapes.AddEllipse(2400, 1150, 1000, 1900);


//Applying animation effects on both shapes
shape1.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral;
shape2.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxOut;


//Setting the animation order for both shapes. According to below order, shape2
//will animate first and then the shape1
shape1.AnimationSettings.AnimationOrder = 2;
shape2.AnimationSettings.AnimationOrder = 1;


//Writing the presentation as a PPT file
pres.Write("C:\\modified.ppt");

 
[Visual Basic]
'Instantiate a Presentation object that represents a PPT file
Dim pres As Presentation = New Presentation("demo.ppt")


'Accessing a slide using its slide position
Dim slide As Slide = pres.GetSlideByPosition(2)


'Adding two shapes to the slide
Dim shape1 As Shape = slide.Shapes.AddRectangle(1400, 1100, 3000, 2000)
Dim shape2 As Shape = slide.Shapes.AddEllipse(2400, 1150, 1000, 1900)


'Applying animation effects on both shapes
shape1.AnimationSettings.EntryEffect = ShapeEntryEffect.Spiral
shape2.AnimationSettings.EntryEffect = ShapeEntryEffect.BoxOut


'Setting the animation order for both shapes. According to below order, shape2
'will animate first and then the shape1
shape1.AnimationSettings.AnimationOrder = 2
shape2.AnimationSettings.AnimationOrder = 1


'Writing the presentation as a PPT file
pres.Write("C:\modified.ppt")

 

Figure : Controlling Animation Order of shapes

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.