求算法!!!!!!!!!!!!!!!!
我做了个像流程图的东西,窗体上有几个可以拖动的动态创建的button 它们之间有连线。
当拖动button时 连线也跟着重新画。有时连线会和其他button重合,(曲折线)
我的画线函数如下怎样判断连线是否与其他button重合?
怎样使和button重合的连线可以绕开所有重合的button???
procedure NewLine(p1,p2:TBitBtn);
var
dp1,dp2:TPoint;
begin
Canvas.Pen.Color :=clred;
dp1:=point(p1.Left+p1.Width div 2,p1.Top+p1.Height);
dp2:=point(p2.Left+p2.Width div 2,p2.top);
if (dp2.Y - dp1.Y) > 15 then
begin
Canvas.Polyline([dp1,point(dp1.X,dp2.Y-10),point(dp2.X,dp2.Y-10),dp2]);
end else
begin
Canvas.PolyLine([dp1,point(dp1.X,dp1.Y+10),point(dp1.X+50,dp1.Y+10),
point(dp1.X+50,dp2.Y-10),point(dp2.X,dp2.Y-10),dp2]);
end;
end;
请各位大侠指点!