public static IEnumerable <Path> CreatePaths(DataPath data) { yield return(Visualizer.CreateFillPath(PathFormatter.ToString(data))); foreach (var x in data.Subpaths.SelectMany(Visualizer.CreatePathsForSubpath)) { yield return(x); } }
public static IEnumerable <Path> CreatePathsForSubpath(Subpath subpath) { var source = PathFormatter.ToString(subpath); var hash = BitConverter.GetBytes(source.GetHashCode()); var color = ColorHelper.FromHsb(360f * hash[0] / 255, 0.5f * hash[1] / 255 + 0.5f, 0.5f * hash[2] / 255); var group1 = new GeometryGroup(); group1.Children.Add(Geometry.Parse(source)); group1.Children.Add(new RectangleGeometry(new Rect(subpath.StartPoint.X - 2.5, subpath.StartPoint.Y - 2.5, 5, 5))); foreach (var segment in subpath.Segments) { group1.Children.Add(new EllipseGeometry(new Point(segment.EndPoint.X, segment.EndPoint.Y), 1.5, 1.5)); } yield return(new Path { Data = group1, Stroke = new SolidColorBrush(color), StrokeThickness = 3, Opacity = 0.5 }); var intersections = subpath.ClosedSegments.SelectMany(x => x.Intersections).ToArray(); if (intersections.Length == 0) { yield break; } var group2 = new GeometryGroup(); foreach (var point in intersections) { group2.Children.Add(new EllipseGeometry(new Point(point.X, point.Y), 1, 1)); } yield return(new Path { Data = group2, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2, Opacity = 0.3 }); }
private static bool Equals(Subpath subpath1, Subpath subpath2) { return(PathFormatter.ToString(subpath1) == PathFormatter.ToString(subpath2)); }