Direct2d (3): use floating-point parameters to draw basic Images

Source: Internet
Author: User
{Related method} tdirect2dcanvas. drawellipse (); tdirect2dcanvas. drawline (); tdirect2dcanvas. drawrectangle (); tdirect2dcanvas. drawroundedrectangle (); tdirect2dcanvas. fillellipse (); tdirect2dcanvas. fillrectangle (); tdirect2dcanvas. fillroundedrectangle (); {relevant structure} td2dpoint2f (or d2d_point_2f) // floating point structure; build function d2d1pointf (); implicitly converted from tpoint to vertex (or d2d1_ellipse) // floating point elliptical structure; Construction Function d2d1ellipse (); td2d1rectf (or d2d1_rect_f) // floating point rectangular structure; Construction Function d2d1rectf (); implicit conversion from trect to lift (or lift) // floating point rounded rectangle structure; build function d2d1roundedrect ();
Test Code :
Uses direct2d, d2d1; Procedure outputs (Sender: tobject); var CVS: tdirect2dcanvas; FPT: td2dpoint2f; fleft, ftop: single; begin FPT: = d2d1pointf (clientwidth/2, clientheight/2); fleft: = clientwidth/4; ftop: = clientheight/4; CVS: = tdirect2dcanvas. create (canvas, clientrect); CVs. begindraw; CVs. pen. color: = clred; CVs. pen. width: = 2; CVs. brush. color: = clblack; CVs. fillrectangle (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3); CVs. brush. color: = clgreen; CVs. fillroundedrectangle (d2d1roundedrect (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3), 32, 32); CVs. brush. color: = clblue; CVs. fillellipse (d2d1ellipse (FPT, fleft, ftop); CVs. drawrectangle (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3); CVs. drawroundedrectangle (d2d1roundedrect (d2d1rectf (fleft, ftop, fleft * 3, ftop * 3), 32, 32); CVs. drawellipse (d2d1ellipse (FPT, fleft, ftop); CVs. drawline (d2d1pointf (fleft, ftop), d2d1pointf (fleft * 3, ftop * 3); 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.