mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-29 05:36:10 +02:00
TAChart: Extract RotateRect utility function
git-svn-id: trunk@29309 -
This commit is contained in:
parent
6141a3b5dd
commit
e122e92fcf
@ -258,6 +258,7 @@ function RectIntersectsRect(
|
|||||||
|
|
||||||
function RotatePoint(const APoint: TDoublePoint; AAngle: Double): TDoublePoint; overload;
|
function RotatePoint(const APoint: TDoublePoint; AAngle: Double): TDoublePoint; overload;
|
||||||
function RotatePoint(const APoint: TPoint; AAngle: Double): TPoint; overload;
|
function RotatePoint(const APoint: TPoint; AAngle: Double): TPoint; overload;
|
||||||
|
function RotateRect(const ASize: TPoint; AAngle: Double): TPointArray;
|
||||||
function RoundChecked(A: Double): Integer; inline;
|
function RoundChecked(A: Double): Integer; inline;
|
||||||
|
|
||||||
function SafeInfinity: Double; inline;
|
function SafeInfinity: Double; inline;
|
||||||
@ -780,6 +781,19 @@ begin
|
|||||||
Result.Y := Round(sa * APoint.X + ca * APoint.Y);
|
Result.Y := Round(sa * APoint.X + ca * APoint.Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function RotateRect(const ASize: TPoint; AAngle: Double): TPointArray;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
SetLength(Result, 4);
|
||||||
|
Result[0] := -ASize div 2;
|
||||||
|
Result[2] := Result[0] + ASize;
|
||||||
|
Result[1] := Point(Result[2].X, Result[0].Y);
|
||||||
|
Result[3] := Point(Result[0].X, Result[2].Y);
|
||||||
|
for i := 0 to High(Result) do
|
||||||
|
Result[i] := RotatePoint(Result[i], AAngle);
|
||||||
|
end;
|
||||||
|
|
||||||
function RoundChecked(A: Double): Integer;
|
function RoundChecked(A: Double): Integer;
|
||||||
begin
|
begin
|
||||||
Result := Round(EnsureRange(A, -MaxInt, MaxInt));
|
Result := Round(EnsureRange(A, -MaxInt, MaxInt));
|
||||||
|
@ -548,20 +548,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TGenericChartMarks.GetLabelPolygon(ASize: TPoint): TPointArray;
|
function TGenericChartMarks.GetLabelPolygon(ASize: TPoint): TPointArray;
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
a: Double;
|
|
||||||
begin
|
begin
|
||||||
if IsMarginRequired then
|
if IsMarginRequired then
|
||||||
ASize += Point(MARKS_MARGIN_X, MARKS_MARGIN_Y) * 2;
|
ASize += Point(MARKS_MARGIN_X, MARKS_MARGIN_Y) * 2;
|
||||||
SetLength(Result, 4);
|
Result := RotateRect(ASize, LabelAngle);
|
||||||
Result[0] := -ASize div 2;
|
|
||||||
Result[2] := Result[0] + ASize;
|
|
||||||
Result[1] := Point(Result[2].X, Result[0].Y);
|
|
||||||
Result[3] := Point(Result[0].X, Result[2].Y);
|
|
||||||
a := LabelAngle;
|
|
||||||
for i := 0 to High(Result) do
|
|
||||||
Result[i] := RotatePoint(Result[i], a);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGenericChartMarks.IsMarginRequired: Boolean;
|
function TGenericChartMarks.IsMarginRequired: Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user