This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm1 = Class (Tform)
Procedure Formpaint (Sender:tobject);
Procedure Formclick (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
B:tgpsolidbrush;
Path:tgpgraphicspath;
Rgn:tgpregion;
Matrix:tgpmatrix;
Rectcount:integer;
Rts:array of Tgprect;
I:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
B: = Tgpsolidbrush.create (Makecolor (50, 0, 0, 255));
Path: = Tgpgraphicspath.create;
Path. AddEllipse (Makerect, ClientWidth-40, ClientHeight-20));
Rgn: = tgpregion.create (path);
Matrix: = tgpmatrix.create; {It's just a device in this case, because it needs}
Rectcount: = Rgn. Getregionscanscount (Matrix);
SetLength (RTS, Rectcount);
Rgn. Getregionscans (Matrix, Pgprect (RTS), Rectcount);
Randomize;
For I: = 0 to RectCount-1 do
Begin
B.setcolor (Colorreftoargb (Random ($FFFFFF)));
G.fillrectangle (b, rts[i]);
End
Matrix.free;
Rgn. Free;
Path. Free;
B.free;
G.free;
End
Procedure Tform1.formclick (Sender:tobject);
Begin
Repaint;
End
End.
Form file:object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 217
ClientWidth = 219
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnClick = FormClick
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
end