//區域聯合
var
g : TGPGraphics;
sb: TGPSolidBrush;
region: TGPRegion;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(aclYellowGreen);
region := TGPRegion.Create(MakeRect(50, 0, 50, 150)); {建立區域}
region.Union(MakeRect(0, 50, 150, 50)); {區域聯合}
g.FillRegion(sb, region); {填充}
sb.Free;
region.Free;
g.Free;
end;
//用區域剪切畫板
var
g : TGPGraphics;
sb: TGPSolidBrush;
p: TGPPen;
region: TGPRegion;
font: TGPFont;
begin
g := TGPGraphics.Create(Canvas.Handle);
sb := TGPSolidBrush.Create(aclYellowGreen);
p := TGPPen.Create(aclRed);
font := TGPFont.Create('宋體',12);
region := TGPRegion.Create(MakeRect(50, 0, 50, 150)); {建立區域}
region.Union(MakeRect(0, 50, 150, 50)); {區域聯合}
g.FillRegion(sb, region);
g.SetClip(region); {用區域剪切畫板}
g.DrawLine(p, 0, 0, 100, 100); {測試畫板剪切後的直線}
sb.SetColor(aclBlack);
g.DrawString('萬一萬一萬一', -1, font, MakePoint(20.0,20.0), sb); {測試文本}
sb.Free;
p.Free;
region.Free;
font.Free;
g.Free;
end;