In this example:
Code 1:
Unit unit1; interfaceuses 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); const PT: tpoint = (X: 130; Y: 130); r = 120; colors: array [0 .. 0] of tgpcolor = (aclred); var G: tgpgraphics; P: tgppen; Path: tgpgraphicspath; Pb: tgppathgradientbrush; PTS: array [0 .. 4] of tgppoint; radian: single; I, num: integer; begin for I: = 0 to 4 Do begin radian: = I * (360*2/5) * (PI/180); PTS [I]. x: = pt. X + round (sin (radian) * R); PTS [I]. y: = pt. y-round (COS (radian) * R); end; 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); Pb. setcentercolor (aclyellow); {stroke edge} p: = tgppen. create (aclyellow); G. setsmoothingmode (smoothingmodeantialias); G. drawpath (p, PATH); G. fillpath (Pb, PATH); Pb. free; Path. free; p. free; G. free; end.
Code 2:
Unit unit1; interfaceuses 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); const PT: tpoint = (X: 130; Y: 130); r = 120; colors: array [0 .. 0] of tgpcolor = (aclred); var G: tgpgraphics; P: tgppen; Path: tgpgraphicspath; Pb: tgppathgradientbrush; PTS: array [0 .. 9] of tgppoint; radian: single; I, num: integer; RX: single; begin for I: = 0 to 9 do begin RX: = r; if odd (I) then RX: = r * (1-(SQRT (5)-1)/2); {(SQRT (5)-1)/2 is the golden splitting point, about 0.618} radian: = I * (360/10) * (PI/180); PTS [I]. x: = pt. X + round (sin (radian) * RX); PTS [I]. y: = pt. y-round (COS (radian) * RX); end; 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); Pb. setcentercolor (aclyellow); {stroke edge} p: = tgppen. create (aclyellow); G. setsmoothingmode (smoothingmodeantialias); G. drawpath (p, PATH); G. fillpath (Pb, PATH); Pb. free; Path. free; p. free; G. free; end.
Form file:
object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 238 ClientWidth = 259 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 = 13end