当前位置: > 编程语言 > Delphi教程 >

再学GDI+[46]: 路径 - Create、FillPath、DrawPath

时间:2012-05-14 | 栏目:Delphi教程 | 点击:

本例效果图:

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, GDIPAPI;
procedure TForm1.FormPaint(Sender: TObject);
var
 g: TGPGraphics;
 path: TGPGraphicsPath;
 p: TGPPen;
 b: TGPBrush;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 path := TGPGraphicsPath.Create;
 path.AddLine(10,10,110,110);
 path.AddRectangle(MakeRect(10,10,100,100));
 path.AddEllipse(MakeRect(10,10,100,100));
 p := TGPPen.Create(aclRed);
 b := TGPSolidBrush.Create(aclYellow);
 g.FillPath(b, path);
 g.DrawPath(p, path);
 b.Free;
 p.Free;
 path.Free;
 g.Free;
end;
end.

您可能感兴趣的文章:

相关文章