This example effect chart:
Code files: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;
Pb:tgppathgradientbrush;
Rt:tgprect;
Const
PTS:ARRAY[0..2] of tgppoint = (x:90; Y:10), (x:10; y:160), (x:160; y:160));
COLORS:ARRAY[0..2] of Tgpcolor = (Aclgreen, Aclaqua, Aclblue);
POS:ARRAY[0..2] of single = (0.0, 0.25, 1.0); {The color position requires >=0, <=1, percent}
Begin
Triangle
G: = Tgpgraphics.create (Canvas.handle);
Path: = Tgpgraphicspath.create;
Path. Addpolygon (Pgppoint (@pts), Length (pts));
pb:= tgppathgradientbrush.create (path);
Pb. Setinterpolationcolors (@colors, @pos, Length (colors)); {Setinterpolationcolors}
G.fillpath (Pb, Path);
Rectangle
Pb. Getrectangle (RT); {Getrectangle}
Path. Reset;
Path. AddRectangle (RT);
Pb. Free;
pb:= tgppathgradientbrush.create (path);
Pb. Setinterpolationcolors (@colors, @pos, Length (colors));
G.translatetransform (160, 0);
G.fillpath (Pb, Path);
Elliptic
Path. Reset;
Path. AddEllipse (RT);
Pb. Free;
pb:= tgppathgradientbrush.create (path);
Pb. Setinterpolationcolors (@colors, @pos, Length (colors));
G.translatetransform (160, 0);
G.fillpath (Pb, Path);
Pb. Free;
Path. Free;
G.free;
End
End.
Form file:object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 164
ClientWidth = 491
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
end