//設置多種周邊顏色
var
g: TGPGraphics;
path: TGPGraphicsPath;
pb: TGPPathGradIEntBrush;
colors: array[0..9] of TGPColor;
num: Integer;
const
pts : array[0..9] of TGPPoint =
((x:75 ; y:0 ), (x:100; y:50 ),
(x:150; y:50 ), (x:112; y:75 ),
(x:150; y:150), (x:75 ; y:100),
(x:0 ; y:150), (x:37 ; y:75 ),
(x:0 ; y:50 ), (x:50 ; y:50 ));
begin
g := TGPGraphics.Create(Canvas.Handle);
path:= TGPGraphicsPath.Create;
path.AddLines(PGPPoint(@pts), 10);
pb:= TGPPathGradIEntBrush.Create(path);
pb.SetCenterColor(MakeColor(255, 255, 0, 0));
colors[0] := MakeColor(255, 0, 0, 0);
colors[1] := MakeColor(255, 0, 255, 0);
colors[2] := MakeColor(255, 0, 0, 255);
colors[3] := MakeColor(255, 255, 255, 255);
colors[4] := MakeColor(255, 0, 0, 0);
colors[5] := MakeColor(255, 0, 255, 0);
colors[6] := MakeColor(255, 0, 0, 255);
colors[7] := MakeColor(255, 255, 255, 255);
colors[8] := MakeColor(255, 0, 0, 0);
colors[9] := MakeColor(255, 0, 255, 0);
num := 10;
pb.SetSurroundColors(@colors, num); {設置多種周邊顏色}
g.FillPath(pb, path);
pb.SetGamMacorrection(True); {使用灰度校正}
g.TranslateTransform(200.0, 0.0);
g.FillPath(pb, path);
path.Free;
pb.Free;
g.Free;
end;
//描繪在不同的區域
var
g : TGPGraphics;
pb: TGPPathGradIEntBrush;
p: TGPPen;
colors: array[0..4] of TGPColor;
num: Integer;
const
pts: array[0..4] of TGPPointF =
((x: 0.0 ; y: 0.0),
(x: 160.0; y: 0.0),
(x: 160.0; y: 200.0),
(x: 80.0 ; y: 150.0),
(x: 0.0 ; y: 200.0));
begin
g := TGPGraphics.Create(Canvas.Handle);
pb:= TGPPathGradIEntBrush.Create(PGPPointF(@pts), 5);
colors[0] := MakeColor(255, 255, 0, 0);
colors[1] := MakeColor(255, 0, 255, 0);
colors[2] := MakeColor(255, 0, 255, 0);
colors[3] := MakeColor(255, 0, 0, 255);
colors[4] := MakeColor(255, 255, 0, 0);
num := 5;
pb.SetSurroundColors(@colors, num);
pb.SetCenterColor(MakeColor(255, 255, 255, 255));
g.FillRectangle(pb, MakeRect(0, 0, 180, 220));
p := TGPPen.Create(aclBlack);
g.DrawRectangle(p, MakeRect(0, 0, 180, 220));
p.Free;
pb.Free;
g.Free;
end;