This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Comctrls, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Trackbar3:ttrackbar;
Trackbar4:ttrackbar;
Trackbar5:ttrackbar;
Trackbar6:ttrackbar;
Procedure Formpaint (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Trackbar3change (Sender:tobject);
Procedure Trackbar4change (Sender:tobject);
Procedure Trackbar5change (Sender:tobject);
Procedure Trackbar6change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Trackbar1.max: = 10;
Trackbar2.max: = 10;
Trackbar3.max: = 10;
Trackbar4.max: = 10;
Trackbar5.max: = 10;
Trackbar6.max: = 10;
Trackbar1.position: = Trackbar1.max;
Trackbar2.position: = Trackbar2.min;
Trackbar3.position: = Trackbar3.max;
Trackbar4.position: = Trackbar4.min;
Trackbar5.position: = Trackbar5.max Div 2;
Trackbar6.position: = Trackbar6.max;
End
Procedure Tform1.formpaint (Sender:tobject);
Const
PTS:ARRAY[0..2] of tgppoint = (x:120; Y:10), (x:40; y:140), (x:200; y:140));
COLORS:ARRAY[0..2] of Tgpcolor = (aclred, Aclgreen, Aclyellow);
Var
G:tgpgraphics;
Path:tgpgraphicspath;
Pb:tgppathgradientbrush;
BLENDFACTORS:ARRAY[0..2] of single;
POS:ARRAY[0..2] of single;
Num:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
Path: = Tgpgraphicspath.create;
Path. Addpolygon (Pgppoint (@pts), Length (pts));
PB: = tgppathgradientbrush.create (path);
Num: = Length (colors);
Pb. Setsurroundcolors (@colors, num); {Setblend is only valid when setting surround color}
Blendfactors[0]: = TRACKBAR1.POSITION/10;
BLENDFACTORS[1]: = TRACKBAR2.POSITION/10;
BLENDFACTORS[2]: = TRACKBAR3.POSITION/10;
Pos[0]: = TRACKBAR4.POSITION/10;
POS[1]: = TRACKBAR5.POSITION/10;
POS[2]: = TRACKBAR6.POSITION/10;
Pb. Setblend (@blendFactors, Psingle (@pos), Length (blendfactors));
G.fillpath (Pb, Path);
Pb. Free;
Path. Free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar3change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar4change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar5change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar6change (Sender:tobject);
Begin
Repaint;
End
End.