我的程序中有一颗星星:
<Grid>
<Path Name="starPath" Fill="White" StrokeThickness="1" Stroke="White"
Data="M 127,37 L 104,105 L 34,105 L 91,150 L 69,218 L 127,176 L 187,218 L 164,150 L 223,105 L 151,105 L 127,37">
</Path>
</Grid>
我想让星星变亮,点亮并熄灭缓慢地,并通过动画改变路径的笔触颜色,直到永远重复一次。
我使用了此代码,然后缓慢点亮但迅速点亮并重复:
ColorAnimation animation;
animation = new ColorAnimation();
this.starPath.Stroke = new SolidColorBrush(Colors.Transparent);
animation.To = Colors.White;
animation.Duration = new Duration(TimeSpan.FromMilliseconds(900));
animation.RepeatBehavior = RepeatBehavior.Forever;
this.starPath.Stroke.BeginAnimation(SolidColorBrush.ColorProperty, animation);
星星如何缓慢点亮?
只需添加此行: