mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 07:59:35 +02:00
GraphUtil/DrawArrow: Avoid separate calculation of sin() and cos(). Issue #39983.
This commit is contained in:
parent
1799775107
commit
54efec74f5
@ -220,15 +220,18 @@ end;
|
||||
|
||||
procedure DrawArrow(Canvas: TCanvas; p1, p2: TPoint; ArrowLen: longint;
|
||||
ArrowAngleRad: float; ArrowType: TArrowType);
|
||||
var {NormalizedLineX, NormalizedLineY, LineLen,} LineAngle: float;
|
||||
ArrowPoint1, ArrowPoint2: TPoint;
|
||||
var
|
||||
LineAngle: float;
|
||||
sinAngle, cosAngle: float;
|
||||
ArrowPoint1, ArrowPoint2: TPoint;
|
||||
begin
|
||||
LineAngle:=arctan2(p2.y-p1.y,p2.x-p1.x);
|
||||
ArrowPoint1.x:=round(ArrowLen*cos(pi+LineAngle-ArrowAngleRad))+p2.x;
|
||||
ArrowPoint1.y:=round(ArrowLen*sin(pi+LineAngle-ArrowAngleRad))+p2.y;
|
||||
ArrowPoint2.x:=round(ArrowLen*cos(pi+LineAngle+ArrowAngleRad))+p2.x;
|
||||
ArrowPoint2.y:=round(ArrowLen*sin(pi+LineAngle+ArrowAngleRad))+p2.y;
|
||||
|
||||
SinCos(pi + LineAngle - ArrowAngleRad, sinAngle, cosAngle);
|
||||
ArrowPoint1.x := round(ArrowLen * cosAngle) + p2.x;
|
||||
ArrowPoint1.y := round(ArrowLen * sinAngle) + p2.y;
|
||||
SinCos(pi + LineAngle + ArrowAngleRad, sinAngle, cosAngle);
|
||||
ArrowPoint2.x := round(ArrowLen * cosAngle) + p2.x;
|
||||
ArrowPoint2.y := round(ArrowLen * sinAngle) + p2.y;
|
||||
Canvas.Line(p1,p2);
|
||||
|
||||
case ArrowType of
|
||||
|
Loading…
Reference in New Issue
Block a user