How to set Smooth Start and End for animated shapes in Presentation
The PowerPoint framework is a feature rich .NET PowerPoint class library that can be used by developers to create, read, edit and convert PowerPoint files to PDFs and images programmatically without Office or interop dependencies.
Steps to set Smooth Start and Smooth End effects for the Shapes in presentation:
- Create a new C# console application project.
- Install the Syncfusion.Presentation.WinForms NuGet package as a reference to your .NET Framework applications from NuGet.org
- Include the following namespace in the Program.cs file.
C#
using Syncfusion.Presentation;
VB
Imports Syncfusion.Presentation
- Use the following code example to set Smooth Start and Smooth End effects for the Shapes in presentation
C#
// Create a new presentation. IPresentation ppDoc = Presentation.Create(); // Add a slide to the presentation. ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank); // Add shape on the slide IShape shape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150); // Add animation effect on the slide with shape IEffect effect = ppDoc.Slides[0].Timeline.MainSequence.AddEffect(shape, EffectType.PathSineWave, EffectSubtype.None, EffectTriggerType.OnClick); // Set smooth start as 2 seconds in Accelerate property // Note: Set Accelerate and Decelerate property value in 0.5 ratio. // For example, if you need to set 1 sec means, set value as 0.5f. effect.Timing.Accelerate = 1f; // Set smooth end as 0 seconds in Decelerate property effect.Timing.Decelerate = 0; // Save the presentation file ppDoc.Save("Sample.pptx"); // Close the presentation file ppDoc.Close();
VB
' Create a new presentation. Dim ppDoc As IPresentation = Presentation.Create() ' Add a slide to the presentation. Dim slide As ISlide = ppDoc.Slides.Add(SlideLayoutType.Blank) ' Add shape on the slide Dim shape As IShape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150) 'Add animation effect on the slide with shape Dim effect As IEffect = ppDoc.Slides(0).Timeline.MainSequence.AddEffect(shape, EffectType.PathSineWave, EffectSubtype.None, EffectTriggerType.OnClick) ' Set smooth start as 2 seconds in Accelerate property ' Note Set Accelerate And Decelerate property value in 0.5 ratio. ' For example, if you need to set 1 sec means, set value as 0.5f. effect.Timing.Accelerate = 1.0F ' Set smooth end as 0 seconds in Decelerate property effect.Timing.Decelerate = 0 ' Save the presentation file ppDoc.Save("Sample.pptx") 'Close the presentation file ppDoc.Close()
A complete working sample to set Smooth Start and Smooth End effects for the Shapes in presentation using C# can be downloaded from here
Please find the applied values in Presentation file by opening in Microsoft PowerPoint application.
Explore more about the rich set of Syncfusion PowerPoint Framework features.
Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering a Syncfusion license key in your application to use the components without trail message.