在powerpoint中,动画效果可分为四大类:进入、强调、退出和动作路径,其中,进入和退出包含一些共有的动画效果。当使用spire.presentation给形状添加共有动画效果时,这些效果默认将被应用为进入效果。这篇文章将介绍如何给形状应用退出动画效果。
c#
//加载文档
presentation ppt = new presentation();
ppt.loadfromfile("input.pptx");
//获取第一张幻灯片
islide slide = ppt.slides[0];
rectanglef rect = new rectanglef(50, 200, 200, 200);
//添加形状到幻灯片
ishape cubeshape = slide.shapes.appendshape(shapetype.cube, rect);
//给形状添加“随机线条”动画效果
animationeffectcollection sequence = slide.timeline.mainsequence;
animationeffect effect = sequence.addeffect(cubeshape, animationeffecttype.randombars);
//将动画效果从默认的“进入”效果改为“退出”效果
effect.presetclasstype = timenodepresetclasstype.exit;
//设置随机线条为垂直方向
effect.subtype = animationeffectsubtype.vertical;
//保存文档
ppt.savetofile("exitanimationeffect.pptx", fileformat.pptx2013);
vb.net
'加载文档
dim ppt as new presentation()
ppt.loadfromfile("input.pptx")
'获取第一张幻灯片
dim slide as islide = ppt.slides(0)
dim rect as new rectanglef(50, 200, 200, 200)
'添加形状到幻灯片
dim cubeshape as ishape = slide.shapes.appendshape(shapetype.cube, rect)
'给形状添加“随机线条”动画效果
dim sequence as animationeffectcollection = slide.timeline.mainsequence
dim effect as animationeffect = sequence.addeffect(cubeshape, animationeffecttype.randombars)
'将动画效果从默认的“进入”效果改为“退出”效果
effect.presetclasstype = timenodepresetclasstype.[exit]
'设置随机线条为垂直方向
effect.subtype = animationeffectsubtype.vertical
'保存文档
ppt.savetofile("exitanimationeffect.pptx", fileformat.pptx2013)
效果图: