// Path gradient painter var G: tgpgraphics; Path: tgpgraphicspath; Pb: tgppathgradientbrush; {declare gradient painter} num: integer; const colors: array [0 .. 0] of tgpcolor = (aclaqua); begin G: = tgpgraphics. create (canvas. handle); Path: = tgpgraphicspath. create; Path. addellipse (,); Pb: = tgppathgradientbrush. create (PATH); {create a gradient Paint Brush} Pb. setcentercolor (makecolor (255, 0, 0,255); {center color} num: = 1; Pb. setsurroundcolors (@ colors, num); {surrounding color} {second parameter, which cannot be replaced by constants; it seems to be the index of the first array parameter + 1} G. fillellipse (Pb, 0, 0,166, 88); {the same size as the defined gradient effect} // G. fillpath (Pb, PATH); {directly draw the path.} path. free; Pb. free; G. free; end;
// You can use the pointer of the Dot Array to create a path. Draw var G: tgpgraphics; PTS: array [0 .. 2] of tgppoint; Pb: tgppathgradientbrush; begin G: = tgpgraphics. create (canvas. handle); PTS [0]: = makepoint (100, 0); PTS [1]: = makepoint (200,200); PTS [2]: = makepoint (0,200); Pb: = tgppathgradientbrush. create (pgppoint (@ PTS), 3); G. fillrectangle (Pb, 0, 0,200,200); {No center color and peripheral color are specified, black and white by default} Pb. free; G. free; end;
// Set the center point var G: tgpgraphics; Path: tgpgraphicspath; Pb: tgppathgradientbrush; num: integer; const colors: array [0 .. 0] of tgpcolor = (aclaqua); begin G: = tgpgraphics. create (canvas. handle); Path: = tgpgraphicspath. create; Path. addellipse (0, 0,140, 70); Pb: = tgppathgradientbrush. create (PATH); Pb. setcenterpoint (makepoint (120, 40); {set center point} Pb. setcentercolor (makecolor (255, 0, 0,255); num: = 1; Pb. setsurroundcolors (@ colors, num); G. fillellipse (Pb, 0, 0,140, 70); Path. free; Pb. free; G. free; end;
// Use Grayscale Correction var G: tgpgraphics; Path: tgpgraphicspath; Pb: tgppathgradientbrush; num: integer; const colors: array [0 .. 0] of tgpcolor = (aclaqua); begin G: = tgpgraphics. create (canvas. handle); Path: = tgpgraphicspath. create; Path. addellipse (,); Pb: = tgppathgradientbrush. create (PATH); Pb. setgammacorrection (true); {Grayscale Correction} num: = 1; Pb. setsurroundcolors (@ colors, num); G. fillellipse (Pb, 0, 0,166, 88); Path. free; Pb. free; G. free; end;
// Multiple colors and positions var G: tgpgraphics; PTS: array [0 .. 2] of tgppoint; Pb: tgppathgradientbrush; const colors: array [0 .. 2] of tgpcolor = (aclgreen, aclaqua, aclblue); pos: array [0 .. 2] of single = (0.0, 0.25, 1.0); {the color position must be greater than 0, // set multiple peripheral colors var G: tgpgraphics; Path: tgpgraphicspath; Pb: tgppathgradientbrush; colors: array [0 .. 9] of tgpcolor; num: integer; const PTS: array [0 .. 9] of tgppoint = (X: 75; Y: 0), (X: 100; Y: 50), (X: 150; Y: 50), (X: 112; Y: 75), (X: 150; Y: 150), (X: 75; Y: 100), (X: 0; Y: 150), (X: 37; Y: 75), (X: 0; Y: 50), (X: 50; Y: 50); begin G: = tgpgraphics. create (canvas. handle); Path: = tgpgraphicspath. create; Path. addlines (pgppoint (@ PTS), 10); Pb: = tgppathgradientbrush. create (PATH); Pb. setcentercolor (makecolor (255,255, 0, 0); colors [0]: = makecolor (255, 0, 0, 0); colors [1]: = makecolor (255, 0,255, 0); colors [2]: = makecolor (255, 0, 0,255); colors [3]: = makecolor (255,255,255,255); colors [4]: = makecolor (255, 0, 0, 0); colors [5]: = makecolor (255, 0,255, 0); colors [6]: = makecolor (255, 0, 0,255); colors [7]: = makecolor (255,255,255,255); colors [8]: = makecolor (255, 0, 0, 0); colors [9]: = makecolor (255, 0,255, 0); num: = 10; Pb. setsurroundcolors (@ colors, num); {set multiple peripheral colors} G. fillpath (Pb, PATH); Pb. setgammacorrection (true); {use Grayscale Correction} G. translatetransform (200.0, 0.0); G. fillpath (Pb, PATH); Path. free; Pb. free; G. free; end;
// Depict var G: tgpgraphics; Pb: tgppathgradientbrush; P: tgppen; colors: array [0 .. 4] of tgpcolor; num: integer; const PTS: array [0 .. 4] of tgppointf = (X: 0.0; Y: 0.0), (X: 160.0; Y: 0.0), (X: 160.0; Y: 200.0), (X: 80.0; Y: 150.0), (X: 0.0; Y: 200.0); begin G: = tgpgraphics. create (canvas. handle); Pb: = tgppathgradientbrush. create (pgppointf (@ PTS), 5); colors [0]: = makecolor (255,255, 0, 0); colors [1]: = makecolor (255, 0,255, 0); colors [2]: = makecolor (255, 0,255, 0); colors [3]: = makecolor (255, 0, 0,255); colors [4]: = makecolor (255,255, 0, 0); num: = 5; Pb. setsurroundcolors (@ colors, num); Pb. setcentercolor (makecolor (255,255,255,255); G. fillrectangle (PBS, makerect (0, 0,180,220); P: = tgppen. create (aclblack); G. drawrectangle (p, makerect (0, 0,180,220); p. free; Pb. free; G. free; end;