IGPSolidBrush(實心畫刷)只是在 IGPBrush 的基礎上增加了一個可讀寫的 IGPSolidBrush.Color 屬性.
IGPHatchBrush(陰影畫刷)有三個只讀屬性: 陰影樣式、前景色、背景色; 它們也剛好是 Create 方法的參數.
Create 也可只有前兩個參數, 此時背景色默認為不透明的黑色.
下面的例子展示了陰影畫刷的所有陰影樣式, 效果圖如下:
查看原圖(大圖)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Brush: IGPHatchBrush;
ForeColor, BackColor: TGPColor;
Rect: TGPRect;
i: Integer;
begin
Graphics := TGPGraphics.Create(Handle);
Rect.Initialize(10, 10, 100, 60);
ForeColor := $FFFF0000;
BackColor := $FFFFFF00;
Graphics.Clear($FFFFFFFF);
for i := 0 to 52 do
begin
Brush := TGPHatchBrush.Create(TGPHatchStyle(i), ForeColor, BackColor);
Graphics.FillRectangle(Brush, Rect);
Graphics.DrawString(IntToStr(i),
TGPFont.Create(Canvas.Handle),
TGPPointF.Create(0, 0),
TGPSolidBrush.Create($FF000000));
Graphics.TranslateTransform(0, Rect.Height * 1.2);
if Graphics.Transform.OffsetY > ClIEntHeight - Rect.Height - Rect.Y then
begin
Graphics.TranslateTransform(Rect.X * 1.5 + Rect.Width, -Graphics.Transform.OffsetY);
end;
end;
end;
end.