Introduction to Delphi xe2 firemonkey (10)-common structures such as tpoint, tpointf, tsmallpoint, tsize, trect, and trectf and related methods

Source: Internet
Author: User
They are all structures. tpointf and trectf are newly added, and others are also upgraded. Now they all have rich methods and convenient Operator overloading. There is also a set of related public functions.

This set of content is important because they all come from system. types units, that is, they are not only available in FM.

Tpoint:

 
Create (); // {operator overload} equal; // = notequal; // Add; // + subtract; //-implicit; // It can be converted from tsmallpoint stealth to tpointexplicit; // It can be converted to tsmallpoint {method} distance (); // The setlocation () distance between two points is calculated (); // relocate offset (); // offset add (); // Add subtract (); // subtract iszero (); // whether the data is {data member} X, Y: longint; {test} procedure tform1.button1click (Sender: tobject); var P1, P2, P3: tpoint; begin P1: = tpoint. create (11, 22); p2.create (11, 11); P3: = p1 + P2; showmessagefmt ('% d, % d', [p3.x, p3.y]); // 22,33 p3.setlocation (0, 0); P3: = p1.add (P2); showmessagefmt ('% d, % d', [p3.x, p3.y]); // 22, 33end;
Tpointf: Three more methods than tpoint:

 
Ceiling (); // truncate (); // round (); // procedure tform1.button1click (Sender: tobject); var PF: tpointf; P1, P2, P3: tpoint; begin PF. create (1.4, 1.6); P1: = PF. ceiling; P2: = PF. truncate; P3: = PF. round; showmessagefmt ('% d, % d', [p1.x, p1.y, p2.x, p2.y, p3.x, p3.y]); //, 1, 2 end;
Tsmallpoint: Use less and have fewer members.

 
Create (); // {operator overload} equal; // = notequal; // Add; // + subtract; //-{method} Add (); // Add subtract (); // subtract distance (); // calculate the two-point spacing iszero (); // whether it is [0, 0] point {data member} X, Y: smallint;
Tsize:

Create (); // {operator overload} equal; // = notequal; // Add; // + subtract; //-{method} Add (); // Add subtract (); // subtract distance (); // calculate the two-point spacing iszero (); // whether it is [0, 0] point {attribute} width; // height; // {data member} CX, Cy: single;
Trect:

Create (); // normalization of rectangles at the time of creation and at the same time; see normalizerect () method {operator overload} equal; // = notequal; // Add; // + (union) multiply; // * (intersection) {class method} empty; // obtain an empty trect object; inline intersect; // obtain the union of the intersection rectangles of the two rectangles; // obtain the Union rectangle of the two rectangles {method} normalizerect (); // normalization rectangle; When top> bottom or left> right, it will replace the data to make it reasonable. isempty (); // whether it is empty contains (); // whether it contains the specified vertex or the specified rectangle intersectswith (); // whether to cross intersect () with the specified rectangle (); // perform the Union () operation on the intersection with the specified rectangle; // perform the Union () operation on the union with the specified rectangle; // offset setlocation (); // set the new origin inflate (); // enlarge the rectangle (retain the center point) centerpoint (); // obtain the center point splitrect (); // cut, tsplitrecttype enumeration (left, top, right, bottom) indicates the side to be retained {attribute} width: integer; // it is convenient to have these attributes Height: integer; // size: tsize; // location: tpoint; // {data structure, which is the same as the former} (left, top, right, bottom: longint) or (topleft, bottomright: tpoint)
Trectf: There are only three more methods for decimal choice when converting to trect than trect.

 
Ceiling (); // truncate (); // round ();//
Related public functions and processes:

{Function} predict rect (); // judge whether trect or trectf is equal rect (); // construct trectrectf (); // construct trectfnormalizerectf (); // define a trectfnormalizerect () from the tpointf array Specification; // normalize trectfrectwidth (); // obtain the rectangle width rectheight (); // obtain the rectangle height rectcenter (); // Let the rectangle center bounds () in another specified rectangle; // construct a rectangle point () based on the origin, width, and height; // construct a tpointpointf (); // construct tpointfminpoint (); // compare the two points and return a small (Y is prioritized) scalepoint (); // move the smallpoint () according to the specified proportion (); // construct tsmallpointptinrect (); // judge whether the vertex is in the specified rectangle ptincircle (); // determine whether the vertex is in the circle with the specified center and radius intersectrect (); // determine whether the two rectangles overlap unionrect (); // combine the two rectangles isrectempty (); // determine whether the rectangle is empty offsetrect (); // offset the rectangle centerpoint (); // obtain the center point of the rectangle splitrect (); // the center point of the rectangle is removed from the centeredrect (); // calculate the intermediate transitional rectangle of the two rectangles; it should be the intersectrectf () used for animation (); // output unionrectf () at the intersection of the two rectangles; // output the union of the two rectangles {procedure} multiplyrect (); // scale down the rectangle by ratio inflaterect (); // scale down the rectangle by volume

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.