这是我的代码。 “ Pt1”是直线的起点列表,而“ Pt2”是直线的终点列表。我已经可以画线并确定相交的点。我唯一的问题是如何在这两点之间绘制跳跃或曲线/弧线。
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
for (int i = 0; i < Pt1.Count; i++)
{
try
{
bool segments_intersect;
PointF first = Intersection;
FindIntersection(Pt1[i], Pt2[i], NewPt1, NewPt2, out LinesIntersect, out segments_intersect, out Intersection, out Close1, out Close2);
//here is the jump event
if (segments_intersect)
{
Point[] pt =
{
//I would like to know the formula here how to make a curve by adding a points in these line
new Point(
Convert.ToInt32(
first.X * Pt1[i]
.X / 2),
Convert.ToInt32(first.Y - 5)),
new Point(Convert.ToInt32(first.X), Convert.ToInt32(first.Y)),
new Point(Convert.ToInt32(first.X - 5), Convert.ToInt32(first.Y - 5)),
};
e.Graphics.DrawLine(Pens.Blue, Pt1[i], Pt2[i]);
e.Graphics.DrawCurve(Pens.Blue, pt);
}
else
{
//if there is no intersection
e.Graphics.DrawLine(Pens.Blue, Pt1[i], Pt2[i]);
}
}
catch
{
e.Graphics.DrawLine(Pens.Blue, Pt1[i], Pt2[i]);
}
}
if (IsDrawing)
{
e.Graphics.DrawLine(Pens.Red, NewPt1, NewPt2);
}
}
这是代码。我已经有十字路口的课程了。我的问题只是如何在相交点绘制曲线。