IGPGraphicsPath.PointCount; // 點總數
IGPGraphicsPath.PathPoints; // 點數組, 浮點型
IGPGraphicsPath.PathPointsI; // 點數組, 整型
IGPGraphicsPath.PathTypes; // 點類型數組
IGPGraphicsPath.PathData; // 點與點類型數據, IGPPathData 類型
IGPGraphicsPath.GetLastPoint; // 尾點
IGPGraphicsPath.Reverse; // 反轉點順序
IGPGraphicsPath.GetBounds(); // 獲取包圍矩形
{ 關於點類型(它是個 Byte 值) }
0 // 指示此點是圖形的起始點
1 // 指示此點是線段的兩個終結點之一
3 // 指示此點是立方貝塞爾樣條的終結點或控制點。
$7 // 對三個低序位(指示點類型)之外的所有位進行掩碼
$20 // 指定此點是一個標記
$80 // 指定此點是閉合子路徑(圖形)中的最後一點
//實際讀出的值如果不是這樣, 應該是改點有雙重身份.
PathPoints、PathTypes、PathData 測試圖:
PathPoints、PathTypes、PathData 測試代碼:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Path: IGPGraphicsPath;
Brush,BrushPt,BrushText: IGPSolidBrush;
Pt: TGPPointF;
PtType: Byte;
i: Integer;
begin
Graphics := TGPGraphics.Create(Handle);
Brush := TGPSolidBrush.Create($FFC0C0C0);
BrushPt := TGPSolidBrush.Create($80FF0000);
BrushText := TGPSolidBrush.Create($FF000000);
Path := TGPGraphicsPath.Create;
Path.AddString('A', TGPFontFamily.Create('Arial Black'), [], 200, TGPPoint.Create(0,0), nil);
Path.AddEllipse(210, 76, 100, 144);
Graphics.FillPath(Brush, Path);
for i := 0 to Path.PointCount - 1 do
begin
Pt := Path.PathPoints[i];
PtType := Path.PathTypes[i];
//上兩行也可以寫作:
//Pt := Path.PathData.Points[i];
//PtType := Path.PathData.Types[i];
Graphics.FillRectangle(BrushPt, Pt.X-3, Pt.Y-3, 6, 6);
Graphics.DrawString(Format('%x', [PtType]), TGPFont.Create(Canvas.Handle), Pt, BrushText);
end;
end;
GetLastPoint、Reverse、PathPointsI 測試代碼:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Path: IGPGraphicsPath;
PtStart: TGPPoint;
PtEnd: TGPPointF;
begin
Path := TGPGraphicsPath.Create;
Path.AddRectangle(TGPRect.Create(1, 2, 3, 4));
PtStart := Path.PathPointsI[0];
PtEnd := Path.GetLastPoint;
ShowMessageFmt('%d;%d, %g;%g', [PtStart.X, PtStart.Y, PtEnd.X, PtEnd.Y]);
{ (1;2), (1;6) }
Path.Reverse;
PtStart := Path.PathPointsI[0];
PtEnd := Path.GetLastPoint;
ShowMessageFmt('%d;%d, %g;%g', [PtStart.X, PtStart.Y, PtEnd.X, PtEnd.Y]);
{ (1;6), (1;2) }
end;
GetBounds 測試圖:
GetBounds 測試代碼:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Path: IGPGraphicsPath;
Pen: IGPPen;
Rect: TGPRect;
begin
Graphics := TGPGraphics.Create(Handle);
Pen := TGPPen.Create($FFFF0000, 2);
Path := TGPGraphicsPath.Create;
Path.AddLine(20, 20, 150, 100);
Graphics.DrawPath(Pen, Path);
Pen.Width := 1;
Pen.Color := $FFC0C0C0;
Path.GetBounds(Rect);
Graphics.DrawRectangle(Pen, Rect);
end;