public static Path GetParticlePath(Point start, Point end, byte[] rgb, Storyboard sb, PathGeometry geometry, double particleTime) { 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), }; DoubleAnimation pda0 = StoryBoard.Animation3(particleTime); 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); }
public static DependencyObject[] GetAnimation(Point startPoint, Point endPoint, double diameter, PathGeometry geometry, double l, byte[] rgb, Storyboard m_Sb, double m_Speed, string m_PointData, FrameworkElement elm) { System.Windows.Controls.Grid grid = GetRunPoint(rgb, m_PointData, elm); Ellipse ell = PathEllipse.GetToEllipse(diameter, diameter, rgb, endPoint); double pointTime = l / m_Speed; StoryBoard.AddPointToStoryboard(grid, ell, m_Sb, geometry, l, startPoint, endPoint, pointTime); return(new DependencyObject[] { grid, ell }); }