//创建并填充区域
var
g: TGPGraphics;
sb: TGPSolidBrush;
region: TGPRegion; {定义区域}
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(aclGold);
region := TGPRegion.Create(MakeRect(50, 50, 150, 150)); {建立区域}
g.FillRegion(sb, region); {填充区域}
sb.Free;
region.Free;
g.Free;
end;
//根据路径建立区域
var
g: TGPGraphics;
path: TGPGraphicsPath;
region: TGPRegion;
sb: TGPSolidBrush;
const
pts: array[0..3] of TGPPoint =
((x:10 ; y:10 ),
(x:150; y:10 ),
(x:100; y:75 ),
(x:100; y:150));
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(aclRed);
path := TGPGraphicsPath.Create;
path.AddPolygon(PGPPoint(@pts), Length(pts));
region := TGPRegion.Create(path); {根据路径建立区域}
g.FillRegion(sb, region);
g.Free;
path.Free;
region.Free;
sb.Free;
end;