C# PPT 为形状设置三维效果

在PPT中,形状是非常重要的元素。3-D形状,立体多元,给人耳目一新的感觉。在幻灯片中添加3-D效果形状,必然会为PPT的整体效果增色不少。为形状设置三维格式时,可设置棱台,轮廓线,表面效果等。

本篇文章,旨在介绍在使用免费的Spire.Presentation,独立创建Powerpoint文档,添加形状,并设置三维效果。感兴趣的朋友,可以从E-iceblue官网下载免费的Spire.Presentation。下载完成后,请将bin文件夹的.dll添加作为引用。友情提示:使用Spire.Presentation可独立创建powerpoint文档。

需要添加的命名空间:

using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

步骤详叙:

步骤一:创建PPT文档。

Presentation presentation = new Presentation();

步骤二:添加形状,设置其位置,大小并填充颜色。

IAutoShape shape1 = presentation.Slides[0].Shapes.AppendShape(ShapeType.RightArrow, new RectangleF(150, 150, 150, 150));
shape1.Fill.FillType = FillFormatType.Solid;
shape1.Fill.SolidColor.KnownColor = KnownColors.RoyalBlue;

步骤三:为该形状设置三维效果。

ShapeThreeD Demo1 = shape1.ThreeD.ShapeThreeD;
//设置表面效果
Demo1.PresetMaterial = PresetMaterialType.Matte;
//设置棱台类型,高度和宽度
Demo1.TopBevel.PresetType = BevelPresetType.ArtDeco;
Demo1.TopBevel.Height = 4;
Demo1.TopBevel.Width = 12;
//设置轮廓线类型,颜色,宽度
Demo1.BevelColorMode = BevelColorType.Contour;
Demo1.ContourColor.KnownColor = KnownColors.LightBlue;
Demo1.ContourWidth = 3.5;

步骤四:再添加一个形状作为对照。

IAutoShape shape2 = presentation.Slides[0].Shapes.AppendShape(ShapeType.Pentagon, new RectangleF(400, 150, 150, 150));
shape2.Fill.FillType = FillFormatType.Solid;
shape2.Fill.SolidColor.KnownColor = KnownColors.LawnGreen;
ShapeThreeD Demo2 = shape2.ThreeD.ShapeThreeD;
Demo2.PresetMaterial = PresetMaterialType.SoftEdge;
Demo2.TopBevel.PresetType = BevelPresetType.SoftRound;
Demo2.TopBevel.Height = 12;
Demo2.TopBevel.Width = 12;
Demo2.BevelColorMode = BevelColorType.Contour;
Demo2.ContourColor.KnownColor = KnownColors.LawnGreen;
Demo2.ContourWidth = 5;

步骤五:保存文档为.pptx,启动查看效果。

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");

效果截图:

完整代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Presentation presentation = new Presentation();
            IAutoShape shape1 = presentation.Slides[0].Shapes.AppendShape(ShapeType.RightArrow, new RectangleF(150, 150, 150, 150));
            shape1.Fill.FillType = FillFormatType.Solid;
            shape1.Fill.SolidColor.KnownColor = KnownColors.RoyalBlue;

ShapeThreeD Demo1 = shape1.ThreeD.ShapeThreeD;
            Demo1.PresetMaterial = PresetMaterialType.Matte;
            Demo1.TopBevel.PresetType = BevelPresetType.ArtDeco;
            Demo1.TopBevel.Height = 4;
            Demo1.TopBevel.Width = 12;
            Demo1.BevelColorMode = BevelColorType.Contour;
            Demo1.ContourColor.KnownColor = KnownColors.LightBlue;
            Demo1.ContourWidth = 3.5;

IAutoShape shape2 = presentation.Slides[0].Shapes.AppendShape(ShapeType.Pentagon, new RectangleF(400, 150, 150, 150));
            shape2.Fill.FillType = FillFormatType.Solid;
            shape2.Fill.SolidColor.KnownColor = KnownColors.LawnGreen;
            ShapeThreeD Demo2 = shape2.ThreeD.ShapeThreeD;
            Demo2.PresetMaterial = PresetMaterialType.SoftEdge;
            Demo2.TopBevel.PresetType = BevelPresetType.SoftRound;
            Demo2.TopBevel.Height = 12;
            Demo2.TopBevel.Width = 12;
            Demo2.BevelColorMode = BevelColorType.Contour;
            Demo2.ContourColor.KnownColor = KnownColors.LawnGreen;
            Demo2.ContourWidth = 5;

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("result.pptx");
        }
    }
}

感谢阅读,如有疑问,请留言。

时间: 2024-08-30 12:30:16

C# PPT 为形状设置三维效果的相关文章

百度地图三维效果实现

之前用百度地图都是用的二维地图,现在发现百度地图支持三维效果,欲实现三维效果只需添加如下两句代码即可: map.setMapType(BMAP_PERSPECTIVE_MAP);     //修改地图类型为3D地图 map.setCurrentCity("北京市");  //设置当前城市 ,整体代码如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type"

PPT文本框设置实用技巧分享

我们在制作PPT的过程中,几乎都要与文字打交道,文字一般都是在插入的文本框中输入的,通过输入文本框默认的文字与边框的距离,可以是文本框显得更加的美观:那么,具体是怎样操作的呢?下面将方法告诉大家! 主要有4个方法: 设置文本框间距.设置对齐方式.设置字符间距.设置行距.具体如下: 1.设置文本框间距 鼠标选中形状,然后右键-设置形状格式-文本框-左右上下边距设置为:0厘米. 2.设置对齐方式 鼠标选中形状-点击开始选项卡-选择两端对齐. 3.设置字符间距 鼠标选中形状-点击开始选项卡-字符间距-

winform-windowsmediaplayer设置可视化效果之条形

winform导入windowsmediaplayer这个COM组件,他的默认可视化效果为: 而我们需要的可视化效果为: 则我们可以通过代码更改可视化效果: //设置可视化效果 public void SetCurrentEffectPreset(int value) { WindowsIdentity identiry = WindowsIdentity.GetCurrent(); String path = String.Format(@"{0}\Software\Microsoft\Med

图片设置3D效果

/** * 图片绘制3d效果 * @param srcImage * @param radius * @param border * @param padding * @return * @throws IOException */ public static BufferedImage draw3D(BufferedImage srcImage, int radius, int border, int padding, Color bgColor) throws IOException{ in

如何给before和after伪元素设置js效果

目录 [1]动态嵌入CSS[2]添加类名 [3]setAttribute [4]添加样式表 [5]修改样式表 前面的话 无法直接给before和after伪元素设置js效果 例子说明 现在需要为(id为box,内容为"我是测试内容"的div)添加(:before内容为"前缀",颜色为红色的伪类) <!DOCTYPE html> <html lang="en"> <head> <meta charset=&

Win桌面三维效果

进入Windows 7旗舰版的桌面后,按住组合键Win + Ctrl + Tab即可将三维效果定在某个位置. 现在提供一种建立快捷方式的办法: 在桌面空白处右击鼠标-新建-快捷方式,在弹出的对话框中输入C:\Windows\System32\rundll32.exe DwmApi #105,“C”为Windows 7所在分区-然后单击下一步完成,就在桌面上创建了一个开启立体窗口转换的快捷方式. Win桌面三维效果

PPT投影仪演示设置

这两天部门参加一个科技比赛,要用PPT进行演示,平时都是直接脱稿演讲的,但是这次时间太紧,而且产品也不是我自己参与的,因此,为保险起见,还是重新掌握了一下PPT投影仪演示的方法,以防万一. 这一招的学名叫做:PPT投影仪扩展演示 具体就是让我们再播放幻灯片的时候,扩展屏幕(一般就是投影仪了)只显示幻灯片全屏的内容,而电脑屏幕显示PPT以及演讲备注等内容. 具体设置方法: 1.进入控制面板à显示à更改显示器设置,当你连接上投影仪后,这里就会多出一个设置显示器选项,然后选择扩展屏幕即可 2.打开PP

Android -----paint cap join 理解 ,paint画笔形状设置

引自:http://www.2cto.com/kf/201501/370215.html 网上查了很多资料,对paint的里面的枚举类cap join讲的不是很透彻.在这里自己做一个比较深入的研究. 首先说Cap,比较形象的解释就是 用来控制我们的画笔在离开画板时候留下的最后一点图形,比如矩形,圆形等.不懂?那接着往下看. 先看看源码: /** * The Cap specifies the treatment for the beginning and ending of * stroked

xml文件的根节点layout_width或者layout_height设置无效果的原因分析

在android开发中相信大家对ListView.GridView等组建都很熟悉,在使用它们的时候需要自己配置相关的Adapter,并且配置现骨干的xml文件作为ListView等组建的子View,这些xml文件在Adapter的getView方法中调用.例如: public View getView(int position, View convertView, ViewGroup parent) { if(convertView==null) { convertView = App.getL