Learn more about GDI + [69]: path painter (9)-difference between setinterpolationcolors and setsurroundcolors

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, comctrls, stdctrls, role; Type tform1 = Class (tform) Procedure formpaint (sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; Procedure tform1.formpaint (Sender: tobject); const colors: array [0 .. 3] of tgpcolor = (aclred, aclyellow, aclgreen, aclblue); pos: array [0 .. 3] of single = (0.0, 0.2, 0.6, 1.0); {it seems that the data at both ends must be 0 and 1} var G: tgpgraphics; Path: tgpgraphicspath; Pb: tgppathgradientbrush; num: integer; PTS: array of tgppoint; begin G: = tgpgraphics. create (canvas. handle); Path: = tgpgraphicspath. create; {create an elliptical path, draw a brush Based on the path, and then set the color using setinterpolationcolors} path. addellipse (makerect (10, 10, 150,150); Pb: = tgppathgradientbrush. create (PATH); Pb. setinterpolationcolors (@ colors, @ POs, length (POS); G. fillpath (Pb, PATH); {create a path painting brush Based on the elliptical path, and then set the color using setsurroundcolors} Pb. free; Pb: = tgppathgradientbrush. create (PATH); num: = length (POS); Pb. setsurroundcolors (@ colors, num); G. translatetransform (160, 0); G. fillpath (Pb, PATH); {create a path painter Based on the vertex array extracted from the elliptical path, and then set the color using setsurroundcolors} setlength (PTS, path. getpointcount); Path. getpathpoints (pgppoint (PTS), length (PTS); Pb. free; Pb: = tgppathgradientbrush. create (pgppoint (PTS), length (PTS); Pb. setcentercolor (aclwhite); {in this case, the center is black by default. I want white.} num: = length (colors); Pb. setsurroundcolors (@ colors, num); G. translatetransform (160, 0); G. fillpath (Pb, PATH); {create a path painter Based on the vertex array extracted from the elliptical path, and then set the color using setinterpolationcolors} // setlength (PTS, path. getpointcount); // path. getpathpoints (pgppoint (PTS), length (PTS); Pb. free; Pb: = tgppathgradientbrush. create (pgppoint (PTS), length (PTS); // Pb. setcentercolor (aclwhite); {center color is not required here} num: = length (colors); Pb. setinterpolationcolors (@ colors, @ POs, length (POS); G. translatetransform (160, 0); G. fillpath (Pb, PATH); Pb. free; Path. free; G. free; end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 169 clientwidth = 649 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter onpaint = formpaint pixelsperinch = 96 textheight = 13end

  

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.