第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

C#/VB.NET 自定義動畫路徑

標(biāo)簽:
C#

PPT中的动画效果可分为已有内置动画以及自定义动画。设置内置动画,只需直接指定动画效果类型即可。本文主要介绍如何实现自定义动画,即自定义形状动作线性路径。附C#及VB.NET代码供参考。

程序运行环境如下:

  • .Net Framework 4.8
  • Visual Studio
  • Spire.Presentation.dll 6.4.5

所需引用的必要程序集文件如下图:

图片描述

C#

using Spire.Presentation; using Spire.Presentation.Collections; using Spire.Presentation.Drawing.Animation; using System.Drawing; namespace CustomAnimation
{ class Program
    { static void Main(string[] args)
        { //创建一个幻灯片文档(新建的文档已默认包含一页幻灯片)
            Presentation ppt = new Presentation();
            ISlide slide = ppt.Slides[0];//获取第一页空白幻灯片 //添加形状(指定形状坐标、大小及相关格式设置)
            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, new RectangleF(100, 50, 180, 180));
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient;
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.SkyBlue);
            shape.Fill.Gradient.GradientStops.Append(1, KnownColors.Pink);
            shape.ShapeStyle.LineColor.Color = Color.White; //给形状设置动画效果
            AnimationEffect effect = ppt.Slides[0].Timeline.MainSequence.AddEffect(shape, AnimationEffectType.PathUser);
            CommonBehaviorCollection common = effect.CommonBehaviorCollection;
            AnimationMotion motion = (AnimationMotion)common[0];
            motion.Origin = AnimationMotionOrigin.Layout;
            motion.PathEditMode = AnimationMotionPathEditMode.Relative;
            MotionPath moinPath = new MotionPath();
            moinPath.Add(MotionCommandPathType.MoveTo, new PointF[] { new PointF(0, 0) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.18f, 0.18f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(-0.1f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.25f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
            moinPath.Add(MotionCommandPathType.End, new PointF[] { }, MotionPathPointsType.CurveStraight, true);
            motion.Path = moinPath; //保存文档
            ppt.SaveToFile("CustomAnimation.pptx", FileFormat.Pptx2013);
            System.Diagnostics.Process.Start("CustomAnimation.pptx");
        }
    }
}

VB.NET

Imports Spire.Presentation Imports Spire.Presentation.Collections Imports Spire.Presentation.Drawing.Animation Imports System.Drawing Namespace CustomAnimation Class Program Private Shared Sub Main(args As String()) '创建一个幻灯片文档(新建的文档已默认包含一页幻灯片)
            Dim ppt As New Presentation() Dim slide As ISlide = ppt.Slides(0) '获取第一页空白幻灯片
            '添加形状(指定形状坐标、大小及相关格式设置)
            Dim shape As IAutoShape = slide.Shapes.AppendShape(ShapeType.FivePointedStar, New RectangleF(100, 50, 180, 180))
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.SkyBlue)
            shape.Fill.Gradient.GradientStops.Append(1, KnownColors.Pink)
            shape.ShapeStyle.LineColor.Color = Color.White '给形状设置动画效果
            Dim effect As AnimationEffect = ppt.Slides(0).Timeline.MainSequence.AddEffect(shape, AnimationEffectType.PathUser) Dim common As CommonBehaviorCollection = effect.CommonBehaviorCollection Dim motion As AnimationMotion = DirectCast(common(0), AnimationMotion)
            motion.Origin = AnimationMotionOrigin.Layout
            motion.PathEditMode = AnimationMotionPathEditMode.Relative Dim moinPath As New MotionPath()
            moinPath.Add(MotionCommandPathType.MoveTo, New PointF() {New PointF(0, 0)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(0.18F, 0.18F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(-0.1F, 0.2F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.LineTo, New PointF() {New PointF(0.25F, 0.2F)}, MotionPathPointsType.CurveAuto, True)
            moinPath.Add(MotionCommandPathType.[End], New PointF() {}, MotionPathPointsType.CurveStraight, True)
            motion.Path = moinPath '保存文档
            ppt.SaveToFile("CustomAnimation.pptx", FileFormat.Pptx2013)
            System.Diagnostics.Process.Start("CustomAnimation.pptx") End Sub
    End Class
End Namespace

动画效果:

图片描述

作者: E-iceblue
出处:https://www.cnblogs.com/Yesi/p/14743875.html

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消