The igplineargradientbrush. Blend attribute corresponds to an igpblend object;
The two parameters in tgpblend. Create (factors, positions); are single-type arrays,
Factors color intensity factor, positions is the ratio of location offset.
For the gradient of the two colors, the above two arrays should be composed of three elements; the default effect is [0, 0.5, 1].
Test:
TestCode:
Uses gdiplus; procedure merge (Sender: tobject); var graphics: igpgraphics; rect: tgprectf; brush: gradient; stringformat: gradient; Font: igpfont; brushtext: igpsolidbrush; begin graphics: = tgpgraphics. create (canvas. handle); rect. initialize (20, 10, clientwidth-40, 30); brush: = tgplineargradientbrush. create (rect, $ ffff0000, $ ff0000ff, 0); stringformat: = tgpstringformat. create; stringformat. alignment: = stringalignmentcenter; stringformat. linealignment: = stringalignmentfar; Font: = tgpfont. create (canvas. handle); brushtext: = tgpsolidbrush. create ($ ffcccc); brush. blend: = tgpblend. create ([0, 0.5, 1], [0, 0.5, 1]); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.5, 1], [0, 0.5, 1]', Font, rect, stringformat, brushtext); // brush. blend: = tgpblend. create ([0, 0.5, 1], [0, 0.2, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.5, 1], [0, 0.2, 1]', Font, rect, stringformat, brushtext); brush. blend: = tgpblend. create ([0, 0.5, 1], [0, 0.8, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.5, 1], [0, 0.8, 1]', Font, rect, stringformat, brushtext); // brush. blend: = tgpblend. create ([0, 0.2, 1], [0, 0.5, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.2, 1], [0, 0.5, 1]', Font, rect, stringformat, brushtext); brush. blend: = tgpblend. create ([0, 0.8, 1], [0, 0.5, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.8, 1], [0, 0.5, 1]', Font, rect, stringformat, brushtext); // brush. blend: = tgpblend. create ([0, 0.2, 1], [0, 0.2, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.2, 1], [0, 0.2, 1]', Font, rect, stringformat, brushtext); brush. blend: = tgpblend. create ([0, 0.8, 1], [0, 0.8, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.8, 1], [0, 0.8, 1]', Font, rect, stringformat, brushtext); // brush. blend: = tgpblend. create ([0, 0.2, 1], [0, 0.8, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.2, 1], [0, 0.8, 1]', Font, rect, stringformat, brushtext); brush. blend: = tgpblend. create ([0, 0.8, 1], [0, 0.2, 1]); graphics. translatetransform (0, rect. Y + rect. height); graphics. fillrectangle (brush, rect); graphics. drawstring ('[0, 0.8, 1], [0, 0.2, 1]', Font, rect, stringformat, brushtext); end;