按照评论中的要求,我解释了我最终用来制作我的动物重刑:
我依靠Animated Polyline Interpolations in Silverlight和或多或少直接使用此代码 - “窃取”PointCollectionInterpolator.cs类。
然后,我有我的方法来创建我需要的多边形,并准备动画:
private void CreatePolygon(TextBox txtbx, string prop, Color curcol)
{
PointCollectionInterpolator pci = new PointCollectionInterpolator();
pci.Points1 = new PointCollection() // Start Points
{
new Point(...),
new Point(...),
new Point(...),
new Point(...),
};
pci.Points2 = new PointCollection() // End Points
{
new Point(...),
new Point(...),
new Point(...),
new Point(...),
};
Polygon tmpply = new Polygon();
LayoutRoot.Children.Add(tmpply);
tmpply.Points = pci.InterpolatedPoints;
DoubleAnimation animpci = new DoubleAnimation();
animpci.Duration = someDuration;
animpci.From = 0.0;
animpci.To = 1.0;
Storyboard.SetTarget(animpci, pci);
Storyboard.SetTargetProperty(animpci, new PropertyPath("(Progress)"));
myStoryBoard.Children.Add(animpci);
}
然后在一些随机事件处理,我开始动画。另外,所以我可以重复使用该方法,将端点集合移动到起点集合中,并用新的端点更新插补器。 (记住设置进度为0.0 ...)因此,每当处理程序触发时,多边形将无缝地变形为新的。
private void SomeEventHandler(object sender, RoutedEventArgs e)
{
PointCollectionInterpolator polygonPCI =
this.referenceToPointCollectionInterpolator;
polygonPCI.Points1 = polygonPCI.Points2;
polygonPCI.Progress = 0.0;
polygonPCI.Points2 = getNewEndPoints();
myStoryBoard.Begin();
}
回想起来,我将名称从Points1和Points2更改为StartPoints和EndPoints resp。 希望这有助于。 :)
哇,这很快。喜欢这个网站。 :) 感谢您的快速回复。 该代码很容易适应多边形而不是折线 - 并且或多或少地完全符合我的要求。 – Cornelius 2009-08-18 14:44:09
那么upvote怎么样,呵呵呵? :) – 2009-08-18 14:55:39
...你去^。^再次感谢 – Cornelius 2009-08-19 12:25:06