使用path制作各类型动画路径
<Window x:Class="使用path制作各类型动画路径.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Ellipse Height="32" HorizontalAlignment="Left" Margin="63,61,0,0" Name="ellipse1" Stroke="Black" VerticalAlignment="Top" Width="43" Fill="red">
<Ellipse.RenderTransform>
<TransformGroup>
<TranslateTransform X="-75" Y="-75"/><!--修改这个变换值可以使红色椭圆在固定的椭圆轨道上运转-->
<MatrixTransform x:Name="mat1"/>
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Page.Loaded">
<BeginStoryboard>
<Storyboard x:Name="sb1" RepeatBehavior="Forever">
<!--MatrixAnimationUsingPath.PathGeometry属性在后台设置-->
<MatrixAnimationUsingPath x:Name="matUsePath"
Storyboard.TargetName="mat1"
Storyboard.TargetProperty="Matrix"
Duration="0:0:10"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
<Path x:Name="path1" Stroke="Blue">
<Path.Data>
<EllipseGeometry x:Name="elipsGeome" Center="220,150" RadiusX="200" RadiusY="100"/>
</Path.Data>
</Path>
<Button Content="Start" Height="23" HorizontalAlignment="Left" Margin="416,24,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <Ellipse Height="32" HorizontalAlignment="Left" Margin="61,60,0,0" Name="ellipse2" Stroke="Black" VerticalAlignment="Top" Width="43" Fill="blue">
<Ellipse.RenderTransform>
<TransformGroup>
<MatrixTransform x:Name="mat2"/>
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Page.Loaded">
<BeginStoryboard>
<Storyboard x:Name="sb2" RepeatBehavior="Forever">
<MatrixAnimationUsingPath
Storyboard.TargetName="mat2"
Storyboard.TargetProperty="Matrix"
Duration="0:0:10"
>
<!--直接在前台设置MatrixAnimationUsingPath.PathGeometry属性-->
<MatrixAnimationUsingPath.PathGeometry>
<!--Figures这个值需要自己去设置【你怎么设置就怎么转】-->
<PathGeometry Figures="M 10,0 C35,-10 105,-20 140,-30 150,-20 200,-10 300,0 C300,100 200,150 150,100 100,50 50,10 10,0"/>
</MatrixAnimationUsingPath.PathGeometry>
</MatrixAnimationUsingPath>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes; namespace 使用path制作各类型动画路径
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
} private void button1_Click(object sender, RoutedEventArgs e)
{
//设置红色椭圆的Storyboard中"MatrixAnimationUsingPath"的PathGeometry
PathGeometry pg = new PathGeometry();
pg.AddGeometry(elipsGeome);
matUsePath.PathGeometry = pg;
//ellipse1 开始绕椭圆路径旋转
sb1.Begin(ellipse1);
}
}
}
源代码下载:绕固定的轨道旋转
使用path制作各类型动画路径的更多相关文章
- d3.js制作连线动画图和编辑器
此文章为原创文章,原文地址:https://www.cnblogs.com/eagle1098/p/11431679.html 连线动画图 编辑器 效果如上图所示.本项目使用主要d3.jsv4制作,分 ...
- 用CAKeyframeAnimation构建动画路径
复杂路径的动画,我们可以借助关键关键帧动画(CAKeyframeAnimation)来实现,给其的path属性设置相应的路径信息即可. 以下为一个红色的小球按照指定的路径运动的动画. 此动画关键在于如 ...
- 分享:根据svg节点对象类型和路径值转换坐标值
功能用处: 对svg文件的路径节点填充时会使用(相邻两个坐标区域内的四边形的填充颜色不重复). 需要对svg文件中的Path节点或者 Polyline 节点做颜色填充.并且相邻的两个区域之间的颜色不允 ...
- direct path read/write (直接路径读/写)
转载:http://www.dbtan.com/2010/04/direct-path-readwrite.html direct path read/write (直接路径读/写): 直接路径读(d ...
- [翻译] AnimatedPath 动画路径(持续更新)
AnimatedPath动画路径 感谢原作者分享精神,有空补上使用教程 https://github.com/twotoasters/AnimatedPath AnimatedPath explore ...
- [Xcode 实际操作]六、媒体与动画-(8)使用CATransaction Reveal制作渐显动画
目录:[Swift]Xcode实际操作 本文将演示如何制作渐显动画. 图片的不透明度逐渐发生了变化,从而产生作渐显动画的效果. 在项目导航区,打开视图控制器的代码文件[ViewController.s ...
- 推荐几款制作网页滚动动画的 JavaScript 库
这里集合了几款很棒的制作网页滚动动画的 JavaScript 库和插件.它们中,有的可以帮助你在页面滚动的时候添加动感的元素动画,有的则是实现目前非常流行的全屏页面切换动画.相信借助这些插件,你也可以 ...
- 理论制作 Windows 开机动画
第一次接触 Windows 开机动画是 2012 年,那时候魔方的版本号还是 3.12,魔方里面有个很酷炫狂霸拽的功能就是替换 Windows 7 的开机动画.一开始我是在IT之家论坛里下载开机动画, ...
- 【Unity 3D】使用 2DToolkit 插件 制作2D精灵动画
话说博客传图也太麻烦了吧,一个一个文件一个一个传....为什么不能直接粘贴了,自动上传呢... 刚直接粘贴了,结果一张图没有,又重新截一次图,在传了一次...真是太**了 好了,吐槽完了,开始博客吧 ...
随机推荐
- xp2p系统的10点技术创新和经验总结
最近在开发完善九天鸟的xp2p系统,解决了很多技术问题,特此总结下. 第一个项目开发,非常重要,它对建立开发规范.团队协作.开发效率,有很重大的意义. 1.分页前台AJAX异步分页,用咱们自己的fup ...
- [Angular] NgRx/effect, why to use it?
See the current implementaion of code, we have a smart component, and inside the smart component we ...
- 【u216】A+B Problem(aplusb)
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 对于给定的A和B,求A+B的值. [输入格式] 输入文件aplusb.in的第1行为一个整数A,第2行 ...
- Mac修改文件权限:You don’t have permission to save the file
1.从互联网上或者其他途径拿过来的工程代码,往往会报下面的提示: (1)打开文件的时候出现窗口提示You don’t have permission to save the file “project ...
- [转]mnesia数据库学习笔记
mnesia数据库学习笔记一 mnesia数据库学习笔记二 mnesia数据库学习笔记三 mnesia数据库学习笔记四
- 【BZOJ 1021】[SHOI2008]Debt 循环的债务
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1021 [题意] [题解] 设f[i][j][k]表示前i种面值的钱币; 第一个人当前的 ...
- Windows 7 X64位平台下,VC6调试运行程序,中断调试无法退出
用VC6在64位Windows7下调试的时候,如果中断(Shift+F5)调试,程序无法退出. 问题描述: 当点击F5开始一个项目的调试时,程序在设置的断点处停止,这时按下Shift+F5后,vc6可 ...
- VS版本 与 .NET版本以及C#版本之间的关系
版本 .NET Framework版本 Visual Studio版本 发布日期 特性 C# 1.0 .NET Framework 1.0 Visual Studio .NET 2002 2002.1 ...
- 面试问题:Vista与XP的Session 0与Session X的区别
面试问题:Vista与XP的Session 0与Session X的区别 在XXXXX的一次面试中,笔试问题的题目曾提到Session 0.Session 1在Vista和Xp中的区别?现在把答案发上 ...
- C++中的模板编程
一,函数模板 1.函数模板的概念 C++中提供了函数模板,所谓函数模板,实际上是建立一个通用函数,其函数的返回值类型和函数的参数类型不具体指定,用一个虚拟的类型来表示.这个通用函数就被称为函数的模板. ...