//画刷类 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;
//效果图:
![](https://www.cnblogs.com/images/cnblogs_com/del/122519/r_82183.png)
//使用画刷的 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;
//效果图:
![](https://www.cnblogs.com/images/cnblogs_com/del/122519/r_82184.png)