博客
关于我
C# PPT 为形状设置三维效果
阅读量:418 次
发布时间:2019-03-06

本文共 3679 字,大约阅读时间需要 12 分钟。

在PPT制作中,形状的设计往往是吸引观众注意力的重要元素之一。三维效果能够为幻灯片增添层次感与动感,给人耳目一新的感觉。通过Spire.Presentation这款免费的工具,我们可以轻松地在PPT中添加三维形状,并通过设置多种三维效果来提升视觉效果。本文将详细介绍如何使用Spire.Presentation独立创建PPT文档,添加形状并设置三维效果。

需要添加的命名空间

为了操作Spire.Presentation的相关功能,我们需要使用以下命名空间:

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

步骤详述

步骤一:创建PPT文档

首先,我们需要创建一个新的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");

效果截图

通过以上操作,我们可以在PPT中实现形状的三维效果,提升幻灯片的整体视觉效果。以下是完整的代码示例:

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");        }    }}

转载地址:http://jnnkz.baihongyu.com/

你可能感兴趣的文章
Python哪个版本最稳定好用2023.10.19
查看>>
Python和黑客技术的渊源
查看>>
Python和RF编写接口自动化
查看>>
Python和RF编写web自动化
查看>>
python和js哪个难_【Python】记一次学习,Python 与 js 在实现闭包时的差异
查看>>
python和java哪个更值得学——来自知乎高赞回答
查看>>
python和c混合编程 github_在pycharm中使用git版本管理以及同步github的方法
查看>>
python命名空间更改_Python模块xml.etree.ElementTree自动修改xml命名空间键
查看>>
Python命名中尾随下划线有什么好处?
查看>>
Python启动脚本
查看>>
Python听写汇总结果
查看>>
python吊打Excel?屁!那是你不会用!
查看>>
Python合并两张图片 | 先叠透明度再合并 (附Demo)
查看>>
python各进制的表述与转换
查看>>
python各种库安装
查看>>
python可视化matplotlib_如何使用Python中最强大的可视化工具Matplotlib?
查看>>
python可维护性_使用这7大神器,让你的Python 代码更容易于维护
查看>>
Python只运行一次while循环
查看>>
python变量的详细教程_Python零基础入门教程之语法入门[变量](第二期)
查看>>
Python变量命名方法-ChatGPT4o作答
查看>>