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

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

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

本篇文章,旨在介绍在使用免费的Spire.Presentation,独立创建Powerpoint文档,添加形状,并设置三维效果。感兴趣的朋友,可以从免费的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( 150150150150));
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( 400150150150));
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( 150150150150));
            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( 400150150150));
            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/

你可能感兴趣的文章
memset初始化高维数组为-1/0
查看>>
Metasploit CGI网关接口渗透测试实战
查看>>
Metasploit Web服务器渗透测试实战
查看>>
MFC模态对话框和非模态对话框
查看>>
Moment.js常见用法总结
查看>>
MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
查看>>
mxGraph改变图形大小重置overlay位置
查看>>
MongoDB可视化客户端管理工具之NoSQLbooster4mongo
查看>>
Mongodb学习总结(1)——常用NoSql数据库比较
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
mongodb定时备份数据库
查看>>
mppt算法详解-ChatGPT4o作答
查看>>
mpvue的使用(一)必要的开发环境
查看>>
MQ 重复消费如何解决?
查看>>
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>