添加动画效果可以让powerpoint文档更加生动和有吸引力。本文将介绍如何使用spire.presentation for java给powerpoint文档中的形状设置动画效果。
import com.spire.presentation.*;
import com.spire.presentation.drawing.fillformattype;
import com.spire.presentation.drawing.animation.animationeffecttype;
import java.awt.*;
import java.awt.geom.rectangle2d;
public class setanimation {
public static void main(string[] args) throws exception {
//创建powerpoint文档
presentation ppt = new presentation();
//添加幻灯片
islide slide = ppt.getslides().get(0);
//添加一个形状到幻灯片
iautoshape shape = slide.getshapes().appendshape(shapetype.cube, new rectangle2d.double(50, 150, 150, 150));
shape.getfill().setfilltype(fillformattype.solid);
shape.getfill().getsolidcolor().setcolor(color.orange);
shape.getshapestyle().getlinecolor().setcolor(color.white);
//给形状设置动画效果
slide.gettimeline().getmainsequence().addeffect(shape, animationeffecttype.faded_swivel);
//保存文档
ppt.savetofile("addanimationtoshape.pptx", fileformat.pptx_2013);
}
}