In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to add, modify and delete animation in C# PowerPoint, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
In order to make the PowerPoint document more beautiful, we usually add animation to the elements in the PowerPoint document, such as shapes, pictures, tables, etc. This article shows you how to use the .NET PowerPoint components Spire.Presentation and C # to programmatically animate shapes in PowerPoint and modify and delete existing animations.
Before we begin, we can take a look at the animation in PowerPoint. In PowerPoint, animation can be roughly divided into the following four categories:
1. Enter
two。 Emphasize
3. Quit
4. Action path
Among them, there are many different preset animation effects under the entry, emphasis and exit types, and some animation effects can also be added, such as the Random Line animation effects under the entry category. You can set horizontal or vertical direction sub-effects (the default is horizontal). The following figure shows how to add animation to PowerPoint:
How to add Animation in Spire.Presentation
Spire.Presentation supports about 151animation effects (which can be seen in the AnimationEffectType enumeration). See the table at the end of the article for these animation effects and their categories and sub-effects.
Before using the following code, you need to download the Spire.Presentation installation and reference Spire.Presentation.dll from the installation path to the project (or you can search for Spire.Presentation from NuGet and install it).
Add Animation
/ / load the document Presentation ppt = new Presentation (); ppt.LoadFromFile ("Input.pptx"); / / get the first slide ISlide slide = ppt.Slides [0]; RectangleF rect = new RectangleF (50,200,200,200); / / add shapes to the slide IShape cubeShape = slide.Shapes.AppendShape (ShapeType.Cube, rect); / / add animation to shapes AnimationEffectCollection sequence = slide.Timeline.MainSequence;AnimationEffect effect = sequence.AddEffect (cubeShape, AnimationEffectType.Bounce) / / Save document ppt.SaveToFile ("Output.pptx", FileFormat.Pptx2013)
Usually the animation effect we add is the "enter" effect by default. The following code describes how to add the "exit" animation effect:
/ / load the document Presentation ppt = new Presentation (); ppt.LoadFromFile ("Input.pptx"); / / get the first slide ISlide slide = ppt.Slides [0]; RectangleF rect = new RectangleF (50,200,200,200); / / add shapes to the slide IShape cubeShape = slide.Shapes.AppendShape (ShapeType.Cube, rect); / / add animation to shapes AnimationEffectCollection sequence = slide.Timeline.MainSequence;AnimationEffect effect = sequence.AddEffect (cubeShape, AnimationEffectType.RandomBars) / / change the animation effect from the default "enter" effect to "exit" effect effect.PresetClassType = TimeNodePresetClassType.Exit;// add sub-effects to the animation effect.Subtype = AnimationEffectSubtype.Vertical; / / Save the document ppt.SaveToFile ("ExitAnimationEffect.pptx", FileFormat.Pptx2013)
Modify animation
We can modify the existing animation in the document. The following code describes how to modify the type and duration of an existing animation.
Modify animation typ
/ / load the document Presentation ppt = new Presentation (); ppt.LoadFromFile ("Output.pptx"); / / get the first slide ISlide slide = ppt.Slides [0]; / / modify the type of the first animation AnimationEffectCollection sequence = slide.Timeline.MainSequence;sequence [0] .AnimationEffectType = AnimationEffectType.GrowAndTurn; / / Save text ppt.SaveToFile ("EditAnimationType.pptx", FileFormat.Pptx2013)
Modification duration
/ / load the document Presentation ppt = new Presentation (); ppt.LoadFromFile ("Output.pptx"); / / get the first slide ISlide slide = ppt.Slides [0]; / / modify the duration of the first animation AnimationEffectCollection sequence = slide.Timeline.MainSequence;sequence [0] .Timing.Duration = 5; / / Save the document ppt.SaveToFile ("EditAnimationTime.pptx", FileFormat.Pptx2013)
Delete animation
/ / load the document Presentation ppt = new Presentation (); ppt.LoadFromFile ("Output.pptx"); / / get the first slide ISlide slide = ppt.Slides [0]; / / delete the first animation AnimationEffectCollection sequence = slide.Timeline.MainSequence;sequence.RemoveAt (0); / / Save the document ppt.SaveToFile ("RemoveAnimation.pptx", FileFormat.Pptx2013)
Schedule (animation effects and their categories and sub-effects in Spire.Presentation):
Animation effect
classification
Sub-effect
Appear
Entrance or Exit
EffectSubtype.None
CurveUpDown
Entrance or Exit
EffectSubtype.None
Ascend
Entrance or Exit
EffectSubtype.None
Blast
Emphasis
EffectSubtype.None
Blinds
Entrance or Exit
EffectSubtype.Horizontal
EffectSubtype.Vertical
Blink
Emphasis
EffectSubtype.None
BoldFlash
Emphasis
EffectSubtype.None
BoldReveal
Emphasis
EffectSubtype.None
Boomerang
Entrance or Exit
EffectSubtype.None
Bounce
Entrance or Exit
EffectSubtype.None
Box
Entrance or Exit
EffectSubtype.In
EffectSubtype.Out
BrushOnColor
Emphasis
EffectSubtype.None
BrushOnUnderline
Emphasis
EffectSubtype.None
CenterRevolve
Entrance or Exit
EffectSubtype.None
ChangeFillColor
Emphasis
EffectSubtype.Instant
EffectSubtype.Gradual
EffectSubtype.GradualAndCycleClockwise
EffectSubtype.GradualAndCycleCounterClockwise
ChangeFont
Emphasis
EffectSubtype.Instant
EffectSubtype.Gradual
ChangeFontColor
Emphasis
EffectSubtype.Instant
EffectSubtype.Gradual
EffectSubtype.GradualAndCycleClockwise
EffectSubtype.GradualAndCycleCounterClockwise
ChangeFontSize
Emphasis
EffectSubtype.Instant
EffectSubtype.Gradual
ChangeFontStyle
Emphasis
EffectSubtype.FontBold
EffectSubtype.FontItalic
EffectSubtype.FontUnderline
ChangeLineColor
Emphasis
EffectSubtype.Instant
EffectSubtype.Gradual
EffectSubtype.GradualAndCycleClockwise
EffectSubtype.GradualAndCycleCounterClockwise
Checkerboard
Entrance or Exit
EffectSubtype.Vertical
EffectSubtype.Across
Circle
Entrance or Exit
EffectSubtype.In
EffectSubtype.Out
ColorBlend
Emphasis
EffectSubtype.None
ColorTypewriter
Entrance or Exit
EffectSubtype.None
ColorWave
Emphasis
EffectSubtype.None
ComplementaryColor
Emphasis
EffectSubtype.None
ComplementaryColor2
Emphasis
EffectSubtype.None
Compress
Entrance or Exit
EffectSubtype.None
ContrastingColor
Emphasis
EffectSubtype.None
Crawl
Entrance or Exit
EffectSubtype.Right
EffectSubtype.Left
EffectSubtype.Top
EffectSubtype.Bottom
Credits
Entrance or Exit
EffectSubtype.None
Custom
-
-
Darken
Emphasis
EffectSubtype.None
Desaturate
Emphasis
EffectSubtype.None
Descend
Entrance or Exit
EffectSubtype.None
Diamond
Entrance or Exit
EffectSubtype.In
EffectSubtype.Out
Dissolve
Entrance or Exit
EffectSubtype.None
EaseInOut
Entrance or Exit
EffectSubtype.None
Expand
Entrance or Exit
EffectSubtype.None
Fade
Entrance or Exit
EffectSubtype.None
FadedSwivel
Entrance or Exit
EffectSubtype.None
FadedZoom
Entrance or Exit
EffectSubtype.None
EffectSubtype.Center
FlashBulb
Emphasis
EffectSubtype.None
FlashOnce
Entrance or Exit
EffectSubtype.None
Flicker
Emphasis
EffectSubtype.None
Flip
Entrance or Exit
EffectSubtype.None
Float
Entrance or Exit
EffectSubtype.None
Fly
Entrance or Exit
EffectSubtype.Right
EffectSubtype.Left
EffectSubtype.Top
EffectSubtype.Bottom
EffectSubtype.TopLeft
EffectSubtype.TopRight
EffectSubtype.BottomLeft
EffectSubtype.BottomRight
Fold
Entrance or Exit
EffectSubtype.None
Glide
Entrance or Exit
EffectSubtype.None
GrowAndTurn
Entrance or Exit
EffectSubtype.None
GrowShrink
Emphasis
EffectSubtype.None
GrowWithColor
Emphasis
EffectSubtype.None
Lighten
Emphasis
EffectSubtype.None
LightSpeed
Entrance or Exit
EffectSubtype.None
Path5PointStar
Path
EffectSubtype.None
Path6PointStar
Path
EffectSubtype.None
Path7PointStar
Path
EffectSubtype.None
Path8PointStar
Path
EffectSubtype.None
PathArcDown
Path
EffectSubtype.None
PathArcLeft
Path
EffectSubtype.None
PathArcRight
Path
EffectSubtype.None
PathArcUp
Path
EffectSubtype.None
PathBean
Path
EffectSubtype.None
PathBounceLeft
Path
EffectSubtype.None
PathBounceRight
Path
EffectSubtype.None
PathBuzzsaw
Path
EffectSubtype.None
PathCircle
Path
EffectSubtype.None
PathCrescentMoon
Path
EffectSubtype.None
PathCurvedSquare
Path
EffectSubtype.None
PathCurvedX
Path
EffectSubtype.None
PathCurvyLeft
Path
EffectSubtype.None
PathCurvyRight
Path
EffectSubtype.None
PathCurvyStar
Path
EffectSubtype.None
PathDecayingWave
Path
EffectSubtype.None
PathDiagonalDownRight
Path
EffectSubtype.None
PathDiagonalUpRight
Path
EffectSubtype.None
PathDiamond
Path
EffectSubtype.None
PathDown
Path
EffectSubtype.None
PathEqualTriangle
Path
EffectSubtype.None
PathFigure8Four
Path
EffectSubtype.None
PathFootball
Path
EffectSubtype.None
PathFunnel
Path
EffectSubtype.None
PathHeart
Path
EffectSubtype.None
PathHeartbeat
Path
EffectSubtype.None
PathHexagon
Path
EffectSubtype.None
PathHorizontalFigure8
Path
EffectSubtype.None
PathInvertedSquare
Path
EffectSubtype.None
PathInvertedTriangle
Path
EffectSubtype.None
PathLeft
Path
EffectSubtype.None
PathLoopdeLoop
Path
EffectSubtype.None
PathNeutron
Path
EffectSubtype.None
PathOctagon
Path
EffectSubtype.None
PathParallelogram
Path
EffectSubtype.None
PathPeanut
Path
EffectSubtype.None
PathPentagon
Path
EffectSubtype.None
PathPlus
Path
EffectSubtype.None
PathPointyStar
Path
EffectSubtype.None
PathRight
Path
EffectSubtype.None
PathRightTriangle
Path
EffectSubtype.None
PathSCurve1
Path
EffectSubtype.None
PathSCurve2
Path
EffectSubtype.None
PathSineWave
Path
EffectSubtype.None
PathSpiralLeft
Path
EffectSubtype.None
PathSpiralRight
Path
EffectSubtype.None
PathSpring
Path
EffectSubtype.None
PathSquare
Path
EffectSubtype.None
PathStairsDown
Path
EffectSubtype.None
PathSwoosh
Path
EffectSubtype.None
PathTeardrop
Path
EffectSubtype.None
PathTrapezoid
Path
EffectSubtype.None
PathTurnDown
Path
EffectSubtype.None
PathTurnRight
Path
EffectSubtype.None
PathTurnUp
Path
EffectSubtype.None
PathTurnUpRight
Path
EffectSubtype.None
PathUp
Path
EffectSubtype.None
PathUser
Path
EffectSubtype.None
PathVerticalFigure8
Path
EffectSubtype.None
PathWave
Path
EffectSubtype.None
PathZigzag
Path
EffectSubtype.None
Peek
Entrance or Exit
EffectSubtype.Bottom
EffectSubtype.Left
EffectSubtype.Right
EffectSubtype.Top
Pinwheel
Entrance or Exit
EffectSubtype.None
Plus
Entrance or Exit
EffectSubtype.In
EffectSubtype.Out
RandomBars
Entrance or Exit
EffectSubtype.Horizontal
EffectSubtype.Vertical
RandomEffects
Entrance or Exit
EffectSubtype.None
RiseUp
Entrance
EffectSubtype.None
Shimmer
Emphasis
EffectSubtype.None
Sling
Entrance or Exit
EffectSubtype.None
Spin
Emphasis
EffectSubtype.None
Spinner
Emphasis
EffectSubtype.None
Spiral
Entrance or Exit
EffectSubtype.None
Split
Entrance or Exit
EffectSubtype.HorizontalIn
EffectSubtype.HorizontalOut
EffectSubtype.VerticalIn
EffectSubtype.VerticalOut
Stretch
Entrance or Exit
EffectSubtype.Right
EffectSubtype.Left
EffectSubtype.Top
EffectSubtype.Bottom
EffectSubtype.Across
Strips
Entrance or Exit
EffectSubtype.UpLeft
EffectSubtype.UpRight
EffectSubtype.DownLeft
EffectSubtype.DownRight
StyleEmphasis
Emphasis
EffectSubtype.None
Swish
Entrance or Exit
EffectSubtype.None
Swivel
Entrance or Exit
EffectSubtype.Horizontal
EffectSubtype.Vertical
Teeter
Emphasis
EffectSubtype.None
Thread
Emphasis
EffectSubtype.None
Transparency
Emphasis
EffectSubtype.None
Unfold
Entrance or Exit
EffectSubtype.None
VerticalGrow
Emphasis
EffectSubtype.None
Wave
Emphasis
EffectSubtype.None
Wedge
Entrance or Exit
EffectSubtype.None
Wheel
Entrance or Exit
EffectSubtype.Wheel1
EffectSubtype.Wheel2
EffectSubtype.Wheel3
EffectSubtype.Wheel4
EffectSubtype.Wheel8
Whip
Entrance or Exit
EffectSubtype.None
Wipe
Entrance or Exit
EffectSubtype.Top
EffectSubtype.Right
EffectSubtype.Bottom
EffectSubtype.Left
Magnify
Entrance or Exit
EffectSubtype.None
Zoom
Entrance or Exit
EffectSubtype.In
EffectSubtype.Out
EffectSubtype.InCenter-only for Entrance type
EffectSubtype.OutBottom-only for Entrance type
EffectSubtype.OutSlightly
EffectSubtype.InSlightly
EffectSubtype.OutCenter-only for Exit type
EffectSubtype.InBottom-only for Exit type
Note: Entrance means "enter", Exit means "exit", Emphasis means "emphasis", Path means "action path"; EffectSubtype.None means that the effect has no child effect.
The above is all the content of the article "how to add, modify and delete animation in C # PowerPoint". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.