PathAnimation
使用Blend制作PathAnimation
1:选中Path转换为运动路径
2:选择目标对象
PathAnimation使用动态的Path
PathAnimation动画在播放的时候,PahtGeometry是已经确定的,不会改变,不会实时的根据Path的改变动画进行调整,所以是不能进行绑定
只有在每一次需要播放动画之前读取相关的Path的Data,读取当前的PathGeometry然后开始动画
<Path x:Name="path" Stroke="DarkGray" StrokeThickness="3">
<Path.Data>
<PathGeometry>
<PathFigure
StartPoint="{Binding Center, ElementName=ptStart}">
<BezierSegment
Point1="{Binding Center, ElementName=ptCtrl1}"
Point2="{Binding Center, ElementName=ptCtrl2}"
Point3="{Binding Center, ElementName=ptEnd}"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
private void Button_Click(object sender, RoutedEventArgs e)
{
Canvas.SetLeft(this.truck, -this.truck.ActualWidth / );
Canvas.SetTop(this.truck, -this.truck.ActualHeight / );
this.truck.RenderTransformOrigin = new Point(0.5, 0.5); MatrixTransform matrix = new MatrixTransform();
this.truck.RenderTransform = matrix; NameScope.SetNameScope(this, new NameScope());
this.RegisterName("matrix", matrix); MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
matrixAnimation.PathGeometry = this.path.Data.GetFlattenedPathGeometry();
matrixAnimation.Duration = new Duration(TimeSpan.FromSeconds()); //matrixAnimation.AutoReverse = true; //重复
//matrixAnimation.IsOffsetCumulative = !matrixAnimation.AutoReverse;
//matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
matrixAnimation.DoesRotateWithTangent = false; //旋转 Storyboard story = new Storyboard();
story.Children.Add(matrixAnimation);
Storyboard.SetTargetName(matrixAnimation, "matrix");
Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
story.Begin(this);
}
PathAnimation的更多相关文章
- WPF中的PathAnimation(路径动画)
原文:WPF中的PathAnimation(路径动画) WPF中的PathAnimation(路径动画) ...
- 26.Qt Quick QML-RotationAnimation、PathAnimation、SmoothedAnimation、Behavior、PauseAnimation、SequentialAnimation和ParallelAnimation
1.RotationAnimationRotationAnimation也是继承于PropertyAnimation组件,但是它有点特殊,它只需要指定taget目标对象,并且不需要指定property ...
- iOS CoreAnimation详解(一) 有关Layer的动画
以前由于项目需要 也写了一些动画 ,但是知识不系统,很散.这段时间趁着项目完成的空袭,来跟着大神的脚步系统的总结一下iOS中Core Animation的知识点. 原博客地址:http://blog. ...
- 利用layer的mask属性实现逐渐揭示的动画效果
github上又看到个不错的动画(https://github.com/rounak/RJImageLoader),如图: 所以就想来自己实现以下 不试不知道,这个动画还真不是看上去那么简单,我自己想 ...
- iOS 动画绘制线条颜色渐变的折线图
效果图 .................... 概述 现状 折线图的应用比较广泛,为了增强用户体验,很多应用中都嵌入了折线图.折线图可以更加直观的表示数据的变化.网络上有很多绘制折线图的demo,有 ...
- pyqt官方示例
文件夹 PATH 列表 卷序列号为 00000058 F027:7BEC C:. ├─activeqt │ └─webbrowser │ ├─icons │ └─pycache ├─animation ...
- iOS 动画组
其实早在一个多月以前就已经实现了动作组播放的功能,不过当时感觉好像没有什么难度并没有放在心上,今天突然要用到动画组,发现已经忘记了,所以又将原来的代码翻出来看了下.最后决定还是写下来,以备不时之需.动 ...
- CAShapeLayer(持续更新)
CAShapeLayer 之前讲过CALayer动画相关知识,再来看看更加复杂的CAShapeLayer相关的动画知识. 普通CALayer在被初始化时是需要给一个frame值的,这个frame值一般 ...
- iOS简易柱状图(带动画)--新手入门篇
叨逼叨 好久没更新博客了,才几个月,发生了好多事情,处理了好多事情.不变的是写代码依然在继续. 做点啥子 看看objective-c的书,学着写了个柱状图,只是练习的demo而已,iOS上的图表控件已 ...
随机推荐
- S3
S3是Amazon EMR的一部分,它提供了一些Wikipedia的浏览统计数据,这些浏览数据的格式便于Spark测试.
- Ubuntu安装Burg
友情提示:本文只介绍了如何安装Burg,没有关于卸载Burg的相关说明.事实上,我后来直接新装了12.04,我没有卸载Burg的经验.考虑到Burg事关系统引导的大事,安装的话按本文来做应该没有问题, ...
- SQL语句查找重复记录
select * from AM_C4_ENTRY t where t.created_by in ( select t.created_by from AM_C4_ENTRY t group by ...
- jgroups 入门
官网地址:http://www.jgroups.org/ 聊天室示例:http://www.jgroups.org/tutorial/html/ch02.html 2.1. JGroups overv ...
- JDBC 与 ODBC 区别
一. 二.
- 转载sublime text3中package Control
Sublime Text 3 安装Package Control 原来Subl3安装Package Control很麻烦,现在简单的方法来了 一.简单的安装方法 使用Ctrl+`快捷键或者通过View ...
- poj1061 青蛙的约会 扩展欧几里德的应用
这个题解得改一下,开始接触数论,这道题目一开始是看了别人的思路做的,后来我又继续以这种方法去做题,发现很困难,学长告诉我先看书,把各种词的定义看懂了,再好好学习,我做了几道朴素的欧几里德,尽管是小学生 ...
- SpringMVC+JPA使用注入的方式环境搭建
----------------------------------------------------DAO--------------------------------------------- ...
- Magento开发文档(一):Magento入门
开始之前,首先声明下,Magento开发者手册由Alan Storm发表在Magento官方网站上.总共分八个部分,由浅入深的介绍了Magento的MVC架构及Magento中使用的比较特殊的EAV模 ...
- kafka分布式消息队列 — 基本概念介绍
[http://www.inter12.org/archives/818] 这个应该算是之前比较火热的词了,一直没时间抽出来看看.一个新东西出来,肯定是为了解决某些问题,不然不会有它的市场.先简单看下 ...