//畫刷類 TBrush 有三個重要屬性:
Color、Style、Bitmap.
{Style: 樣式; Delphi 為畫刷定義了樣式枚舉 TBrushStyle, 包含以下樣式:}bsSolid
bsClear
bsHorizontal
bsVertical
bsFDiagonal
bsBDiagonal
bsCross
bsDiagCross
//下面小程序展示了上面的其中填充樣式:var
i,n: Integer;
r: TRect;
begin
Canvas.Pen.Color := clRed;
Canvas.Pen.Width := 1;
n := 10;
for i := 0 to 7 do
begin
Canvas.Brush.Color := clYellow;
Canvas.Brush.Style := TBrushStyle(i);
r := Rect(n, 10, n+36, ClientHeight-10);
Canvas.FillRect(r);
Canvas.Rectangle(r);
n := n + 48;
end;
end;
//效果圖:
//使用畫刷的 Bitmap 屬性則可以使用圖片填充.procedure TForm1.FormClick(Sender: TObject);
var
bit: TBitmap;
begin
bit := TBitmap.Create;
bit.LoadFromFile('c:\temp\bg.bmp');
Canvas.Brush.Bitmap := bit;
Canvas.Ellipse(0, 0, ClientWidth, ClientHeight);
bit.Free;
end;
//效果圖: