TAChart: Extract RotateRect utility function

git-svn-id: trunk@29309 -
This commit is contained in:
ask 2011-02-02 05:33:37 +00:00
parent 6141a3b5dd
commit e122e92fcf
2 changed files with 15 additions and 11 deletions

View File

@ -258,6 +258,7 @@ function RectIntersectsRect(
function RotatePoint(const APoint: TDoublePoint; AAngle: Double): TDoublePoint; 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 SafeInfinity: Double; inline;
@ -780,6 +781,19 @@ begin
Result.Y := Round(sa * APoint.X + ca * APoint.Y);
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;
begin
Result := Round(EnsureRange(A, -MaxInt, MaxInt));

View File

@ -548,20 +548,10 @@ begin
end;
function TGenericChartMarks.GetLabelPolygon(ASize: TPoint): TPointArray;
var
i: Integer;
a: Double;
begin
if IsMarginRequired then
ASize += Point(MARKS_MARGIN_X, MARKS_MARGIN_Y) * 2;
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);
a := LabelAngle;
for i := 0 to High(Result) do
Result[i] := RotatePoint(Result[i], a);
Result := RotateRect(ASize, LabelAngle);
end;
function TGenericChartMarks.IsMarginRequired: Boolean;