TAChart: Extract CopyPoints function

git-svn-id: trunk@30203 -
This commit is contained in:
ask 2011-04-05 18:59:26 +00:00
parent 80cc108bec
commit 4d9fc7f139
2 changed files with 17 additions and 13 deletions

View File

@ -80,7 +80,7 @@ type
implementation
uses
SysUtils {$IFDEF USE_FTFONT}, TAGeometry{$ENDIF};
SysUtils, TAGeometry;
type
TFPCanvasHelperCrack = class(TFPCanvasHelper);
@ -92,16 +92,6 @@ begin
d.DoCopyProps(ASrc);
end;
function CopyArray(
const A: array of TPoint; AStart, ACount: Integer): TPointArray;
var
i: Integer;
begin
SetLength(Result, ACount);
for i := 0 to ACount - 1 do
Result[i] := A[i + AStart];
end;
{ TFPCanvasDrawer }
procedure TFPCanvasDrawer.AddToFontOrientation(ADelta: Integer);
@ -202,7 +192,7 @@ begin
if (ANumPts < 0) and (AStartIndex = 0) then
FCanvas.Polygon(APoints)
else
FCanvas.Polygon(CopyArray(APoints, AStartIndex, ANumPts));
FCanvas.Polygon(CopyPoints(APoints, AStartIndex, ANumPts));
end;
procedure TFPCanvasDrawer.Polyline(
@ -213,7 +203,7 @@ begin
if (ANumPts < 0) and (AStartIndex = 0) then
FCanvas.Polyline(APoints)
else
FCanvas.Polyline(CopyArray(APoints, AStartIndex, ANumPts));
FCanvas.Polyline(CopyPoints(APoints, AStartIndex, ANumPts));
end;
procedure TFPCanvasDrawer.PrepareSimplePen(AColor: TChartColor);

View File

@ -23,6 +23,8 @@ interface
uses
TAChartUtils, Types;
function CopyPoints(
APoints: array of TPoint; AStartIndex, ANumPts: Integer): TPointArray;
function DoublePoint(AX, AY: Double): TDoublePoint; inline;
function DoubleRect(AX1, AY1, AX2, AY2: Double): TDoubleRect; inline;
procedure ExpandRect(var ARect: TDoubleRect; const APoint: TDoublePoint); inline;
@ -78,6 +80,18 @@ uses
function PointLineSide(AP, A1, A2: TPoint): TValueSign; forward;
function CopyPoints(
APoints: array of TPoint; AStartIndex, ANumPts: Integer): TPointArray;
var
i: Integer;
begin
if ANumPts = -1 then
ANumPts := Length(APoints) - AStartIndex;
SetLength(Result, ANumPts);
for i := 0 to ANumPts - 1 do
Result[i] := APoints[i + AStartIndex];
end;
function DoublePoint(AX, AY: Double): TDoublePoint; inline;
begin
Result.X := AX;