This method also returns a PathGeometry which is then used to determine the Intersection between the curve and the shapes.
private static PathGeometry DrawLine(Canvas canvas, double X1, double Y1, double X2, double Y2, Color color)
{
QuadraticBezierSegment qbs = new QuadraticBezierSegment(new Point(X2, Y1), new Point(X2, Y2), true);
PathSegmentCollection pscollection = new PathSegmentCollection();
pscollection.Add(qbs);
PathFigure pf = new PathFigure();
pf.Segments = pscollection;
pf.StartPoint = new Point(X1, Y1);
PathFigureCollection pfcollection = new PathFigureCollection();
pfcollection.Add(pf);
PathGeometry pathGeometry = new PathGeometry();
pathGeometry.Figures = pfcollection;
Path path = new Path();
path.Data = pathGeometry;
path.Stroke = new SolidColorBrush(color);
path.StrokeThickness = 2;
Canvas.SetZIndex(path, (int)Layer.Line);
canvas.Children.Add(path);
return pathGeometry;
}
No comments:
Post a Comment