再学GDI+[18]: FillEllipse、TGPHatchBrush(阴影画刷)

TGPHatchBrush.Create(
 hatchStyle: THatchStyle;    {阴影样式, 见下表}
 foreColor: TGPColor;      {前景色}
 backColor: TGPColor = aclBlack {背景色, 是可选值, 默认是黑色}
);

本例效果图:

代码文件:unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, ComCtrls, StdCtrls, ExtCtrls;
type
 TForm1 = class(TForm)
  ColorBox1: TColorBox;
  ColorBox2: TColorBox;
  ComboBox1: TComboBox;
  procedure FormCreate(Sender: TObject);
  procedure FormPaint(Sender: TObject);
  procedure ComboBox1Change(Sender: TObject);
  procedure ColorBox1Change(Sender: TObject);
  procedure ColorBox2Change(Sender: TObject);
 end;
var
 Form1: TForm1;
implementation
{$R *.dfm}
uses GDIPOBJ, GDIPAPI, TypInfo;
procedure TForm1.FormCreate(Sender: TObject);
var
 i: Integer;
begin
 {把画刷样式枚举 HatchStyle 中的所有项添加到列表}
 for i := 0 to Integer(HatchStyleTotal) - 1 do
  ComboBox1.Items.Add(GetEnumName(TypeInfo(HatchStyle), i));
 {给三个列表初始值}
 ComboBox1.ItemIndex := 0;
 ColorBox1.ItemIndex := 16;
 ColorBox2.ItemIndex := 3;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
 g: TGPGraphics;
 r: TGPRect;
 hb: TGPHatchBrush;
 fColor,bColor: TGPColor;
 hbStyle: HatchStyle;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 g.Clear(MakeColor(255,255,255));
 r := MakeRect(20, 60, ClientWidth - 40, ClientHeight - 70);
 hbStyle := HatchStyle(ComboBox1.ItemIndex);  {列表的序号和对应的枚举值是一样的}
 fColor := ColorRefToARGB(ColorBox1.Selected); {前景色}
 bColor := ColorRefToARGB(ColorBox2.Selected); {背景色}
 {建立样式画刷}
 hb := TGPHatchBrush.Create(hbStyle, fColor, bColor);
 g.FillEllipse(hb, r);
 hb.Free;
 g.Free;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
 Repaint;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
 Repaint;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
 Repaint;
end;
end.

时间: 2024-10-30 13:09:08

再学GDI+[18]: FillEllipse、TGPHatchBrush(阴影画刷)的相关文章

Delphi GDI+学习记录(8): 阴影画刷

//阴影画刷 var g: TGPGraphics; hb: TGPHatchBrush; begin g := TGPGraphics.Create(Canvas.Handle); hb := TGPHatchBrush.Create(HatchStyleHorizontal, aclRed, aclYellow); {参数1是阴影样式; 参数2是前景色; 参数3是背景色, 参数3可选, 默认黑色} g.FillEllipse(hb, 11, 11, 222, 111); hb.Free; g

再学GDI+[40]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, CheckLst; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; procedure FormCreate(Sender: TObject); proce

再学GDI+[30]: TGPPen

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; procedure FormCreate(Sender: TObject); procedure FormP

再学GDI+[69]: 路径画刷(9)

SetInterpolationColors 与 SetSurroundColors 的区别 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls; type TForm1 = class(TForm) procedure FormPaint(Sen

再学GDI+[65]: 路径画刷(5)

本例效果图: 代码文件: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 GDIPOBJ

再学GDI+[19]: TGPTextureBrush(纹理画刷)

TGPTextureBrush.Create( image: TGPImage; {用于画刷的图像} ); 本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); end; var Form

再学GDI+[20]: TGPTextureBrush与TWrapMode

TGPTextureBrush.Create( image: TGPImage; {用于画刷的图像} wrapMode: TWrapMode = WrapModeTile {平铺样式, 是可选值, 见下表} ); 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm

Delphi GDI+学习记录(9): 纹理画刷

//纹理画刷 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);

Delphi GDI+学习记录(6): 使用画刷建立画笔

//使用画刷建立画笔 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(tb,36); {参数 1 是画刷; 参数 2 是笔宽