Gdiplus [12]: Other construction methods of igplineargradientbrush

Source: Internet
Author: User
Method 2: tgplineargradientbrush. Create (rectangle, color 1, color 2, gradient mode );

Third Construction Method: tgplineargradientbrush. Create (rectangle, color 1, color 2, angle );

In the third construction method, the "angle" (X axis, clockwise) is equivalent to the custom gradient mode. The following two testsCodeThe results are the same.

In addition, the third construction method also has a Boolean parameter with the default value of false, indicating whether the specified angle is affected by other transformations.

Test:


Test 1:

Uses gdiplus; Procedure injection (Sender: tobject); const C1 = $ ffff0000; C2 = $ ff0000ff; var graphics: igpgraphics; rect, rectbrush: tgprect; brush: cursor; begin graphics: = tgpgraphics. create (canvas. handle); rect. initialize (10, 10,200,150); rectbrush. initialize (rect. X + rect. width Div 8, rect. Y + rect. height Div 8, rect. width Div 4, rect. height Div 4); // lineargradientmodehorizontal is the default value of the brush: = tgplineargradientbrush. create (rectbrush, C1, C2, lineargradientmodehorizontal); graphics. fillrectangle (brush, rect); graphics. translatetransform (0, rect. height + rect. y); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, lineargradientmodevertical); graphics. fillrectangle (brush, rect); graphics. translatetransform (rect. width + rect. x,-graphics. transform. offsety); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, lineargradientmodeforwarddiagonal); graphics. fillrectangle (brush, rect); graphics. translatetransform (0, rect. height + rect. y); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, lineargradientmodebackwarddiagonal); graphics. fillrectangle (brush, rect); end;
 
   
 

Test 2:

Uses gdiplus; Procedure injection (Sender: tobject); const C1 = $ ffff0000; C2 = $ ff0000ff; var graphics: igpgraphics; rect, rectbrush: tgprect; brush: cursor; begin graphics: = tgpgraphics. create (canvas. handle); rect. initialize (10, 10,200,150); rectbrush. initialize (rect. X + rect. width Div 8, rect. Y + rect. height Div 8, rect. width Div 4, rect. height Div 4); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, 0); graphics. fillrectangle (brush, rect); graphics. translatetransform (0, rect. height + rect. y); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, 90); graphics. fillrectangle (brush, rect); graphics. translatetransform (rect. width + rect. x,-graphics. transform. offsety); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, 45); graphics. fillrectangle (brush, rect); graphics. translatetransform (0, rect. height + rect. y); brush: = tgplineargradientbrush. create (rectbrush, C1, C2, 135); graphics. fillrectangle (brush, rect); 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.