【问题标题】:Animating arc segment in WPFWPF中的动画圆弧段
【发布时间】:2012-11-10 18:17:59
【问题描述】:

我们如何在 WPF 中为圆弧段设置动画。下面附上代码。

PathGeometry pg = new PathGeometry();
PathFigure pf = new PathFigure();
LineSegment ls1 = new LineSegment();
LineSegment ls2 = new LineSegment();
ArcSegment arc = new ArcSegment();
double xc = canvas.Width / 2 - 50 + dx;
double yc = canvas.Height / 2 + dy;
double r = 0.7 * xc;   // To control the Explosion generally for all the slices 
pf.IsClosed = true;
pf.StartPoint = new Point(xc, yc);
pf.Segments.Add(ls1);
pf.Segments.Add(arc);
pf.Segments.Add(ls2);
pg.Figures.Add(pf);
path.Data = pg;
arc.IsLargeArc = isLargArc;

ls1.Point = new Point(xc + r * Math.Cos(startAngle), yc + r * Math.Sin(startAngle));
arc.SweepDirection = SweepDirection.Clockwise;

arc.Point = new Point(xc + r * Math.Cos(endAngle), yc + r * Math.Sin(endAngle));
arc.Size = new Size(r, r);
ls2.Point = new Point(xc + r * Math.Cos(endAngle), yc + r * Math.Sin(endAngle));

Duration duration = new Duration(TimeSpan.FromSeconds(5));

pau = new PointAnimationUsingPath();
pau.PathGeometry = pg;
pau.FillBehavior = FillBehavior.Stop;
pau.Duration = new Duration(TimeSpan.FromSeconds(5));

我试图让弧线段像图中一样从一个位置到另一个位置进行动画处理。有一个弧段列表,一个接一个地动画。

【问题讨论】:

    标签: c# wpf animation wpf-animation


    【解决方案1】:

    您可以使用Storyboard 类来制作动画。例如,您可以为位置设置动画,RenderTransform 它应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      • 2011-09-04
      • 1970-01-01
      相关资源
      最近更新 更多