setblendtriangularshaped, Setblendbellshape
This example effect graph (color distortion is serious, because GIF can only accept 256 color):
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;
Radiogroup1:tradiogroup;
Procedure Formcreate (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Radiogroup1click (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Trackbar1.max: = 100;
Trackbar2.max: = 100;
Trackbar1.position: = Trackbar1.max;
Trackbar2.position: = Trackbar2.max;
Trackbar1.showselrange: = False;
Trackbar2.showselrange: = False;
Trackbar1.height: = 23;
Trackbar2.height: = 23;
RadioGroup1.Items.CommaText: = ' blendtriangularshape, Setblendbellshape ';
Radiogroup1.itemindex: = 0;
DoubleBuffered: = True;
End
Procedure Tform1.formpaint (Sender:tobject);
Const
colors:array[0..0] of Tgpcolor = (aclred);
Var
G:tgpgraphics;
Path:tgpgraphicspath;
Pb:tgppathgradientbrush;
Num:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
Path: = Tgpgraphicspath.create;
Path. AddRectangle (Makerect (30,10,160,150));
pb:= tgppathgradientbrush.create (path);
Num: = Length (colors);
Pb. Setsurroundcolors (@colors, num);
Pb. Setcentercolor (Aclyellow);
{The default value for SetBlendTriangularShape and Setblendbellshape parameter 2 is 1.0}
Case Radiogroup1.itemindex of
0:PB. SetBlendTriangularShape (trackbar1.position/100, trackbar2.position/100);
1:PB. Setblendbellshape (trackbar1.position/100, trackbar2.position/100);
End
G.fillpath (Pb, Path);
Pb. Free;
Path. Free;
G.free;
End
Procedure Tform1.radiogroup1click (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
End.