原文:使用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制作各类型动画路径的更多相关文章

  1. d3.js制作连线动画图和编辑器

    此文章为原创文章,原文地址:https://www.cnblogs.com/eagle1098/p/11431679.html 连线动画图 编辑器 效果如上图所示.本项目使用主要d3.jsv4制作,分 ...

  2. 用CAKeyframeAnimation构建动画路径

    复杂路径的动画,我们可以借助关键关键帧动画(CAKeyframeAnimation)来实现,给其的path属性设置相应的路径信息即可. 以下为一个红色的小球按照指定的路径运动的动画. 此动画关键在于如 ...

  3. 分享:根据svg节点对象类型和路径值转换坐标值

    功能用处: 对svg文件的路径节点填充时会使用(相邻两个坐标区域内的四边形的填充颜色不重复). 需要对svg文件中的Path节点或者 Polyline 节点做颜色填充.并且相邻的两个区域之间的颜色不允 ...

  4. direct path read/write (直接路径读/写)

    转载:http://www.dbtan.com/2010/04/direct-path-readwrite.html direct path read/write (直接路径读/写): 直接路径读(d ...

  5. [翻译] AnimatedPath 动画路径(持续更新)

    AnimatedPath动画路径 感谢原作者分享精神,有空补上使用教程 https://github.com/twotoasters/AnimatedPath AnimatedPath explore ...

  6. [Xcode 实际操作]六、媒体与动画-(8)使用CATransaction Reveal制作渐显动画

    目录:[Swift]Xcode实际操作 本文将演示如何制作渐显动画. 图片的不透明度逐渐发生了变化,从而产生作渐显动画的效果. 在项目导航区,打开视图控制器的代码文件[ViewController.s ...

  7. 推荐几款制作网页滚动动画的 JavaScript 库

    这里集合了几款很棒的制作网页滚动动画的 JavaScript 库和插件.它们中,有的可以帮助你在页面滚动的时候添加动感的元素动画,有的则是实现目前非常流行的全屏页面切换动画.相信借助这些插件,你也可以 ...

  8. 理论制作 Windows 开机动画

    第一次接触 Windows 开机动画是 2012 年,那时候魔方的版本号还是 3.12,魔方里面有个很酷炫狂霸拽的功能就是替换 Windows 7 的开机动画.一开始我是在IT之家论坛里下载开机动画, ...

  9. 【Unity 3D】使用 2DToolkit 插件 制作2D精灵动画

    话说博客传图也太麻烦了吧,一个一个文件一个一个传....为什么不能直接粘贴了,自动上传呢... 刚直接粘贴了,结果一张图没有,又重新截一次图,在传了一次...真是太**了 好了,吐槽完了,开始博客吧 ...

随机推荐

  1. [RxJS] Use groupBy in real RxJS applications

    This lesson will show when to apply groupBy in the real world. This RxJS operator is best suited whe ...

  2. js如何遍历表单所有控件

    js如何遍历表单所有控件 一.总结 一句话总结: 1.获取form表单里面的的所有元素:通过formelement.elements,这里form元素通过name属性直接定位 var fele=for ...

  3. Hibernate的数据操作(4.*以上版本)

    Hibernate的基本数据操作 适用于4.* ..sessionFactory的创建区别 public class NewsTest { private Session session = null ...

  4. kettle的job中运行每行

     job中运行每行 有时,我们须要job或转换执行多次.且每次传入的參数都不同.假如你正在做数据迁移的工作,须要导入每天的旧数据,则须要一个job依据指定的日期导入数据,该日期被指定作为參数.假设 ...

  5. MAC 安装下载好的.gz包(不像.dmg直接双击就行了)

    下载之后解压,然后在terminal里敲命令吧: 复制文件:蓝色部分为你解压文件的路径,直接拖到这里就行了$ sudo mv mysql-5.1.45-osx10.6-x86_64文件路径 /usr/ ...

  6. NSUserDefaults:通常用来保存一些小巧的数据,如用户的用户名密码,或者是用户的使用习惯,如是否自动打开背景音乐等。

    1,NSUserDefaults通常用来保存一些小巧的数据,如用户的用户名密码,或者是用户的使用习惯,如是否自动打开背景音乐等. 2,使用它的原因就是:代码简短,使用方便 3,使用方法如下: -(vo ...

  7. sparksql dataset

    java /** *2.0之后使用sparksession即可,不需要再去创建sqlcontext *@author Tele * */ public class Demo { private sta ...

  8. storm 经常使用类

    弄 <dependency> <groupId>org.apache.storm</groupId> <artifactId>storm-core< ...

  9. mingw qt(可以去掉mingwm10.dll、libgcc_s_dw2-1.dll、libstdc++-6.dll的依赖,mingw默认都是动态链接gcc的库而TDM是静态链接gcc库,tdm版本更好用。用aspack压缩没有问题。qt本身不使用异常处理)good

    原文地址:mingw qt作者:孙1东 不使用Qt SDK,使用mingw编译qt源代码所遇问题及解决方法: configure -fast -release -no-exceptions -no-r ...

  10. 从PHP到Node

    花12天时间,断断续续学了PHP和MySQL.学完PHP基础后,本以为很快就能做个中等项目,发现还是不行,可是是学习PHP的时间太短了吧,需要一定强度的练习,学新框架才行.PHP就先放一下吧,就当通过 ...