Gdiplus [14]: blend of igplineargradientbrush

Source: Internet
Author: User
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;
 
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.