//設置路徑畫刷的中心點
var
g: TGPGraphics;
path: TGPGraphicsPath;
pb: TGPPathGradIEntBrush;
num: Integer;
const
colors : array[0..0] of TGPColor = (aclAqua);
begin
g := TGPGraphics.Create(Canvas.Handle);
path:= TGPGraphicsPath.Create;
path.AddEllipse(0, 0, 140, 70);
pb:= TGPPathGradIEntBrush.Create(path);
pb.SetCenterPoint(MakePoint(120, 40)); {設置中心點}
pb.SetCenterColor(MakeColor(255, 0, 0, 255));
num := 1;
pb.SetSurroundColors(@colors, num);
g.FillEllipse(pb, 0, 0, 140, 70);
path.Free;
pb.Free;
g.Free;
end;
//使用灰度校正
var
g: TGPGraphics;
path: TGPGraphicsPath;
pb: TGPPathGradIEntBrush;
num: Integer;
const
colors: array[0..0] of TGPColor = (aclAqua);
begin
g := TGPGraphics.Create(Canvas.Handle);
path := TGPGraphicsPath.Create;
path.AddEllipse(0,0,166,88);
pb := TGPPathGradIEntBrush.Create(path);
pb.SetGamMacorrection(True); {使用灰度校正}
num := 1;
pb.SetSurroundColors(@colors, num);
g.FillEllipse(pb, 0, 0, 166, 88);
path.Free;
pb.Free;
g.Free;
end;
//多種顏色及位置
var
g : TGPGraphics;
pts: array[0..2] of TGPPoint;
pb: TGPPathGradIEntBrush;
const
colors: array[0..2] of TGPColor = (aclGreen, aclAqua, aclBlue);
pos: array[0..2] of Single = (0.0, 0.25, 1.0); {顏色位置需要 >0、<1, 是百分百}
begin
g := TGPGraphics.Create(Canvas.Handle);
pts[0] := MakePoint(100, 0);
pts[1] := MakePoint(200, 200);
pts[2] := MakePoint(0, 200);
pb:= TGPPathGradIEntBrush.Create(PGPPoint(@pts), 3); {根據點數組指針建立路徑畫刷}
pb.SetInterpolationColors(@colors, @pos, 3); {設置顏色位置}
g.FillRectangle(pb, 0, 0, 200, 200);
pb.Free;
g.Free;
end;