Direct2d (5): Drawing custom Images

Source: Internet
Author: User
The following is a test of drawing a diamond using a custom function. Code .
Uses direct2d, d2d1; {custom function for drawing diamond} function getdiamondpath (ptleft, pttop: td2dpoint2f): id2d1pathgeometry; // return path interface var sink: id2d1geometrysink; // The ptright, ptbottom: td2dpoint2f, and begin {calculate the other two points} ptright: = d2d1pointf (pttop. x-ptLeft.x) * 2 + ptleft. x, ptleft. y); ptbottom: = d2d1pointf (pttop. x, (ptleft. y-ptTop.y) * 2 + pttop. y); {build id2d1pathgeometry} d2dfactory. createpathgeometry (result); {create and enable id2d1geometrysink} result. open (sink); {Add graph,} sink. beginfigure (ptleft, d2d1_figure_begin_filled); // option d2d1_figure_begin_filled the logo image can be filled with sink. addline (pttop); sink. addline (ptright); sink. addline (ptbottom); {end the image and close id2d1geometrysink} sink. endfigure (d2d1_figure_end_closed); // option d2d1_figure_end_closed ID image automatically closes the sink. close; end; {draw} procedure tform1.formpaint (Sender: tobject); var path: id2d1pathgeometry; begin path: = getdiamondpath (d2d1pointf (clientwidth/5, clientheight/2 ), d2d1pointf (clientwidth/2, clientheight/5); with tdirect2dcanvas. create (canvas, clientrect) Do begin pen. color: = clred; brush. color: = clyellow; begindraw; fillgeometry (PATH); drawgeometry (PATH); enddraw; 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.