如何为剪切路径设置动画
我正在尝试为剪切路径设置动画。我读自 Silverlight 中的蒙版动画(剪切路径动画)无需一行代码,我应该首先对剪切路径进行动画处理,因此
Data=”M159.67175,104.26108 L177.91812,28.328932 L195.51648,104.43327 L255.0802,102.6104 L206.86984,151.82758 L225.8029,226.56477 L179.0616,179.17046 L129.73396,229.29906 L147.97842,150.63879 L98.650803,101.53297 z”
将更改为,
<Path.Data>
<PathGeometry>
<PathFigure IsClosed=”True” StartPoint=”91.0527648925781,84.0121078491211?>
<LineSegment Point=”118.057907104492,0.549586236476898?/>
<LineSegment Point=”144.103973388672,84.2013778686523?/>
<LineSegment Point=”232.259979248047,82.1977386474609?/>
<LineSegment Point=”160.907287597656,136.2958984375?/>
<LineSegment Point=”188.928756713867,218.444961547852?/>
<LineSegment Point=”119.750289916992,166.350433349609?/>
<LineSegment Point=”46.7439804077148,221.450408935547?/>
<LineSegment Point=”73.7462997436523,134.989212036133?/>
<LineSegment Point=”0.740016639232636,81.0134506225586?/>
</PathFigure>
</PathGeometry>
</Path.Data>
但在对路径进行动画处理后,我的 XAML 仍然看起来像
<Path x:Name="path" Data="M0.5,0.5 L84.5,0.5 L84.5,150.5 L0.5,150.5 z" HorizontalAlignment="Left" Height="151" Margin="76,55,0,0" Stretch="Fill" Stroke="{x:Null}" VerticalAlignment="Top" Width="85" Fill="Black" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
一个短视频关于问题 http://screenr.com/1Wc
I am trying to animate a clipping path. I read from Mask Animations (Clipping Path Animations) In Silverlight Without a Line of Code that I should animate the clipping path 1st so
Data=”M159.67175,104.26108 L177.91812,28.328932 L195.51648,104.43327 L255.0802,102.6104 L206.86984,151.82758 L225.8029,226.56477 L179.0616,179.17046 L129.73396,229.29906 L147.97842,150.63879 L98.650803,101.53297 z”
will be changed to
<Path.Data>
<PathGeometry>
<PathFigure IsClosed=”True” StartPoint=”91.0527648925781,84.0121078491211?>
<LineSegment Point=”118.057907104492,0.549586236476898?/>
<LineSegment Point=”144.103973388672,84.2013778686523?/>
<LineSegment Point=”232.259979248047,82.1977386474609?/>
<LineSegment Point=”160.907287597656,136.2958984375?/>
<LineSegment Point=”188.928756713867,218.444961547852?/>
<LineSegment Point=”119.750289916992,166.350433349609?/>
<LineSegment Point=”46.7439804077148,221.450408935547?/>
<LineSegment Point=”73.7462997436523,134.989212036133?/>
<LineSegment Point=”0.740016639232636,81.0134506225586?/>
</PathFigure>
</PathGeometry>
</Path.Data>
but after animating the path, my XAML still looks like
<Path x:Name="path" Data="M0.5,0.5 L84.5,0.5 L84.5,150.5 L0.5,150.5 z" HorizontalAlignment="Left" Height="151" Margin="76,55,0,0" Stretch="Fill" Stroke="{x:Null}" VerticalAlignment="Top" Width="85" Fill="Black" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
A short video on the problem http://screenr.com/1Wc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在制作动画之前创建剪切路径。
然后,使用直接选择工具(Blend 4 中工具栏上的第二个向下箭头)选择剪切路径。在记录时间线时移动剪辑路径将导致剪辑按照您期望的方式进行动画处理。
这是来自两个矩形的 XAML - 一个具有线性渐变的大矩形,另一个是剪切路径的较小矩形。剪切矩形是动画的并且遵循渐变。
You need to create the clipping path prior to doing the animation.
Then, use the Direct Select tool (the second arrow down on the toolbar in Blend 4) to select the clipping path. Moving the clipping path while recording a timeline will result in the clipping being animated the way you expect.
Here's the XAML from two rectangles - a big one with a linear gradient, and a smaller one that is the clipping path. The clipping rectangle is animated and follows the gradient.