Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 如何设置多边形的动画?(阅读:设置轮廓动画以更改形状)_Silverlight_Animation_Polygon - Fatal编程技术网

Silverlight 如何设置多边形的动画?(阅读:设置轮廓动画以更改形状)

Silverlight 如何设置多边形的动画?(阅读:设置轮廓动画以更改形状),silverlight,animation,polygon,Silverlight,Animation,Polygon,你好 我目前正在做一个Silverlight项目,我想制作一个简单多边形的动画(实际上是一个梯形)。具体来说,我想在一些事件发生后动态移动四点中的两点。我需要/想要调整大小并将其中一条平行边移动到另一个位置 我承认我对Silverlight还是一个新手,还没有找到一个能告诉我这是否可能的消息来源,更不用说如何做到了 我以前使用过动画,所以故事板和动画的一般概念对我来说并不陌生。但是如何在动画中移动多边形的点呢?是否有具有类似光学效果的替代方案(例如,设置路径动画)? 是否有类似的Property

你好

我目前正在做一个Silverlight项目,我想制作一个简单多边形的动画(实际上是一个梯形)。具体来说,我想在一些事件发生后动态移动四点中的两点。我需要/想要调整大小并将其中一条平行边移动到另一个位置

我承认我对Silverlight还是一个新手,还没有找到一个能告诉我这是否可能的消息来源,更不用说如何做到了

我以前使用过动画,所以故事板和动画的一般概念对我来说并不陌生。但是如何在动画中移动多边形的点呢?是否有具有类似光学效果的替代方案(例如,设置路径动画)?
是否有类似的PropertyPath可供我使用

P3AnimBack.SetValue(Storyboard.TargetPropertyProperty, 
    new PropertyPath("(Path.Data).
        (PathGeometry.Figures)[0].(PathFigure.Segments)[0].
        (BezierSegment.Point3)"));
,如在一个


提前谢谢大家。:)

我对Silverlight或.NET中的动画一无所知,但我做了类似的事情:

  • ()
  • ()

根据评论中的要求,我解释了我最终用于制作动画的内容:

我跟进并或多或少直接使用了这段代码——“窃取”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();
}
回想起来,我会将名称从点1和点2分别更改为起点和终点。
希望这有帮助。:)

哇,太快了。一定要喜欢这个网站。:)谢谢你的快速回复。该代码很容易适应多边形而不是多段线-或多或少与我所寻找的内容相符…好了^。^再次感谢您,您可以继续使用您使用的代码。我知道我不介意学点东西;即使我永远不会用它。