//紋理畫刷
var
g: TGPGraphics;
img: TGPImage;
tb: TGPTextureBrush;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\small.jpg');
tb := TGPTextureBrush.Create(img);
g.FillEllipse(tb, 0, 0, Self.ClientWidth, Self.ClientHeight);
img.Free;
tb.Free;
g.Free;
end;
//Matrix
var
g: TGPGraphics;
img: TGPImage;
tb: TGPTextureBrush;
matrix: TGPMatrix;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\x.jpg');
tb := TGPTextureBrush.Create(img);
matrix := TGPMatrix.Create(75.0/640.0, 0.0, 0.0, 75.0/480.0, 0.0, 0.0);
tb.SetTransform(matrix);
g.FillEllipse(tb, 0, 0, Self.ClientWidth, Self.ClientHeight);
matrix.Free;
img.Free;
tb.Free;
g.Free;
end;
//WrapMode
var
g : TGPGraphics;
img: TGPImage;
tb : TGPTextureBrush;
p: TGPPen;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\small.jpg');
tb := TGPTextureBrush.Create(img);
p := TGPPen.Create(MakeColor(255, 0, 0, 0));
tb.SetWrapMode(WrapModeTile);
g.FillRectangle(tb, MakeRect(0, 0, 200, 200));
g.DrawRectangle(p, MakeRect(0, 0, 200, 200));
tb.SetWrapMode(WrapModeTileFlipX);
g.FillRectangle(tb, MakeRect(200, 0, 200, 200));
g.DrawRectangle(p, MakeRect(200, 0, 200, 200));
tb.SetWrapMode(WrapModeTileFlipY);
g.FillRectangle(tb, MakeRect(0, 200, 200, 200));
g.DrawRectangle(p, MakeRect(0, 200, 200, 200));
tb.SetWrapMode(WrapModeTileFlipXY);
g.FillRectangle(tb, MakeRect(200, 200, 200, 200));
g.DrawRectangle(p, MakeRect(200, 200, 200, 200));
img.Free;
tb.Free;
p.Free;
g.Free;
end;
WrapMode 選項:
Delphi 微軟 說明 WrapModeClamp Clamp 紋理或漸變沒有平鋪。 WrapModeTile Tile 平鋪漸變或紋理。 WrapModeTileFlipX TileFlipX 水平反轉紋理或漸變,然後平鋪該紋理或漸變。 WrapModeTileFlipXY TileFlipXY 水平和垂直反轉紋理或漸變,然後平鋪該紋理或漸變。 WrapModeTileFlipY TileFlipY 垂直反轉紋理或漸變,然後平鋪該紋理或漸變。