Direct2d (4): drawgeometry () and fillgeometry ()

Source: Internet
Author: User
The original direct2d only provides the drawing and filling of several simple images (straight lines, rectangles, rounded corners, rectangles). For more set images or paths, use drawgeometry () and fillgeometry ().

Now that you can draw more complex images, you can also draw basic images. First, use drawgeometry () and fillgeometry () to create a rectangle, a rounded rectangle, and an ellipse.

The id2d1geometry interface, id2d1rectanglegeometry, id2d1roundedrectanglegeometry, and id2d1ellipsegeometry are all its sub-interfaces.
Id2d1factory provides methods to implement these three interfaces. You can obtain the id2d1factory interface from d2dfactory.

TestCode:

Uses direct2d, d2d1; procedure invoke (Sender: tobject); var CVS: tdirect2dcanvas; FPT: td2dpoint2f; fleft, ftop: single; iellipse: inline; irectangle: inline; iroundedrectangle; ifacloud: id2d1factory; begin FPT: = d2d1pointf (clientwidth/2, clientheight/2); fleft: = clientwidth/4; ftop: = clientheight/4; ifacloud: = d2dfactory (); ifacloud. createrectanglegeometry (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3), irectangle); ifacloud. createroundedrectanglegeometry (d2d1roundedrect (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3), 32, 32), iroundedrectangle); ifacloud. createellipsegeometry (d2d1ellipse (FPT, fleft, ftop), iellipse); CVS: = tdirect2dcanvas. create (canvas, clientrect); CVs. begindraw; CVs. pen. color: = clred; CVs. brush. color: = clblack; CVs. fillgeometry (irectangle); CVs. brush. color: = clgreen; CVs. fillgeometry (iroundedrectangle); CVs. brush. color: = clblue; CVs. fillgeometry (iellipse); CVs. drawgeometry (irectangle); CVs. drawgeometry (iroundedrectangle); CVs. drawgeometry (iellipse); CVs. enddraw; CVs. free; end; Procedure tform1.formresize (Sender: tobject); begin repaint; 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.