wpf 画五角星函数

public void ABC()
{

var canvas = new Canvas();
Content = canvas;
var points =
new List<Point>()
{
new Point(200, 200),
new Point(400, 200),
new Point(200, 330),
new Point(300, 100),
new Point(400, 330),
new Point(200, 200)
};
var sb = new Storyboard();
for (int i = 0; i < points.Count-1; i++)
{
var lineGeometry = new LineGeometry(points[i], points[i]);
var path =
new Path()
{
Stroke = Brushes.Red,
StrokeThickness = 3,
Data = lineGeometry
};
canvas.Children.Add(path);
var animation =
new PointAnimation(points[i], points[i + 1], new Duration(TimeSpan.FromMilliseconds(1000)))
{
BeginTime = TimeSpan.FromMilliseconds(i * 1000)
};
sb.Children.Add(animation);
RegisterName("s" + i, lineGeometry);
Storyboard.SetTargetName(animation, "s" + i);
Storyboard.SetTargetProperty(animation, new PropertyPath(LineGeometry.StartPointProperty));
}
MouseDown += (s, e) => { sb.Begin(this); };

}

posted @ 2019-10-11 14:40  江湖评谈  阅读(519)  评论(0编辑  收藏  举报