Y
YongSoft
Unregistered / Unconfirmed
GUEST, unregistred user!
var i : Integer;
op : TCADPlan;
p,np,p1,p2 : TPoint;
tgbeta,sinbeta : Extended;
a,b,h,dx,dy : Integer;
Const
al=15;
aw=5;
begin
with ACanvas do begin
Pen.Assign(Self.FPen);
Brush.Assign(Self.FBrush);
if (FSelectColor <> -1) then ACanvas.Pen.Color := FSelectColor;
Brush.Style := bsSolid;
Brush.Color := Pen.Color;
p1 := ScrPoint1;//直线坐标1
p2 := Scrpoint2;;//直线坐标2
PolyLine([p1,p2]);
//以下代码解释一下
p := ScrPoint1;
p.Y := FOwner.Height - p.Y;
np := ScrPoint2;
np.Y := FOwner.Height - np.Y;
h := Trunc(Sqrt(Sqr(np.X - p.X) + Sqr(np.Y - p.Y)));
al := Trunc(iArrowLength );
aw := Trunc(iArrowWidth );
if (h > al) then begin
if ((np.X - p.X) <> 0) then tgbeta := (np.Y - p.Y)/(np.X - p.X) else tgbeta := 4e4900;
sinbeta := (np.Y - p.Y)/h;
b := Trunc(np.Y - iArrowLength*sinbeta);
if (tgbeta <> 0) then a := np.X - Trunc((al*sinbeta)/tgbeta) else a := np.X - 10;
b := FOwner.Height - b;
dy := Trunc(((np.X-p.X)*aw)/h);
dx := Trunc(((np.Y-p.Y)*aw)/h);
np.Y := FOwner.Height - np.Y;
Polygon([np,Point(a + dx, b + dy),Point(a - dx, b - dy){,np}]);
end;
end;
效果 : ------------->
op : TCADPlan;
p,np,p1,p2 : TPoint;
tgbeta,sinbeta : Extended;
a,b,h,dx,dy : Integer;
Const
al=15;
aw=5;
begin
with ACanvas do begin
Pen.Assign(Self.FPen);
Brush.Assign(Self.FBrush);
if (FSelectColor <> -1) then ACanvas.Pen.Color := FSelectColor;
Brush.Style := bsSolid;
Brush.Color := Pen.Color;
p1 := ScrPoint1;//直线坐标1
p2 := Scrpoint2;;//直线坐标2
PolyLine([p1,p2]);
//以下代码解释一下
p := ScrPoint1;
p.Y := FOwner.Height - p.Y;
np := ScrPoint2;
np.Y := FOwner.Height - np.Y;
h := Trunc(Sqrt(Sqr(np.X - p.X) + Sqr(np.Y - p.Y)));
al := Trunc(iArrowLength );
aw := Trunc(iArrowWidth );
if (h > al) then begin
if ((np.X - p.X) <> 0) then tgbeta := (np.Y - p.Y)/(np.X - p.X) else tgbeta := 4e4900;
sinbeta := (np.Y - p.Y)/h;
b := Trunc(np.Y - iArrowLength*sinbeta);
if (tgbeta <> 0) then a := np.X - Trunc((al*sinbeta)/tgbeta) else a := np.X - 10;
b := FOwner.Height - b;
dy := Trunc(((np.X-p.X)*aw)/h);
dx := Trunc(((np.Y-p.Y)*aw)/h);
np.Y := FOwner.Height - np.Y;
Polygon([np,Point(a + dx, b + dy),Point(a - dx, b - dy){,np}]);
end;
end;
效果 : ------------->