In this example:
Code File:
Unit unit1; interfaceuses 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 merge (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 (20, 10, ClientWidth-40, ClientHeight-20); RGN: = tgpregion. create (PATH); matrix: = tgpmatrix. create; {It is just a decoration in this example, because the election requires} 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.
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 = pow.topcenter onclick = formclick onpaint = formpaint pixelsperinch = 96 textheight = 13end