public static Path GetParticlePath(Point start, Point end, byte[] rgb, Storyboard sb, PathGeometry geometry, double l) { Path path = new Path { Style = (Style)Application.Current.Resources["ParticlePathStyle"], Data = geometry, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, rgb[0], rgb[1], rgb[2])), OpacityMask = StoryBoard.GetGradientBrush(start, end), }; //path.ToolTip = string.Format("{0}=>{1}",mapitem.ToString(), toItem.To.ToString()); var particleTime = 1 / l; DoubleAnimation pda0 = StoryBoard.Animation3(particleTime); //Path particlePath = PathEllipse.GetParticlePath(startPoint, endPoint, rgb, m_angle, out double l); //particlePath. Storyboard.SetTarget(pda0, path); Storyboard.SetTargetProperty(pda0, new PropertyPath("(Path.OpacityMask).(GradientBrush.GradientStops)[0].(GradientStop.Offset)")); sb.Children.Add(pda0); var pda1 = StoryBoard.Animation3(particleTime); Storyboard.SetTarget(pda1, path); Storyboard.SetTargetProperty(pda1, new PropertyPath("(Path.OpacityMask).(GradientBrush.GradientStops)[1].(GradientStop.Offset)")); sb.Children.Add(pda1); return(path); }