Direct2d (7): spatial transformation

Source: Internet
Author: User
{Related method} tdirect2dcanvas. rendertarget. settransform (); tdirect2dcanvas. rendertarget. gettransform (); {related structure} td2dmatrix3x2f (or d2d_matrix_3x2_f) // The value of the third column is fixed here (0, 0, 1 ), therefore, the 3*2 matrix is used here. This structure overload the * operator {td2dmatrix3x2fhelper is the method provided by td2dmatrix3x2f (mostly the class method)} identity (); // initialize td2dmatrix3x2f, default Value: _ 11, _ 22 is 1.0, and others are 0 translation (); // translation Scale (); // scale rotation (); // rotate skew (); // diagonal cut determinant (); // calculate the determinant isinvertible (); // whether it is reversible invert (); // reverse operation setproduct (); // multiply {related global functions} d2d1makerotatematrix (); // rotate d2d1makeskewmatrix (); // diagonal tangent trim (); // reversible d2d1invertmatrix (); // Inverse Operation
Test Code :
Uses direct2d, d2d1; Procedure tform1.formpaint (Sender: tobject); var CVS: tdirect2dcanvas; PTS: array [0 .. 2] of tpoint; matrix: td2dmatrix3x2f; begin PTS [0]: = point (clientwidth Div 2, clientheight Div 2); PTS [1]: = point (clientwidth Div 5, clientheight Div 2); PTS [2]: = point (clientwidth Div 2, clientheight Div 5); CVS: = tdirect2dcanvas. create (canvas, clientrect); CVs. begindraw; CVs. brush. style: = bsclear; {Original} CVs. pen. color: = clsilver; CVs. pen. width: = 9; CVs. polygon (PTS); CVs. pen. width: = 2; {translation} matrix: = td2dmatrix3x2f. translation (90, 50); CVs. rendertarget. settransform (matrix); CVs. pen. color: = clred; CVs. polygon (PTS); {scale} matrix: = td2dmatrix3x2f. scale (1.5, 0.5, PTS [0]); CVs. rendertarget. settransform (matrix); CVs. pen. color: = clblue; CVs. polygon (PTS); {rotate} matrix: = td2dmatrix3x2f. rotation (90, PTS [0]); // d2d1makerotatematrix (90, PTS [0], @ matrix); // the same row as CVS. rendertarget. settransform (matrix); CVs. pen. color: = clgreen; CVs. polygon (PTS); {diagonal cut} matrix: = td2dmatrix3x2f. skew (60, 0, PTS [0]); // d2d1makeskewmatrix (60, 10, PTS [0], @ matrix); // the same row as CVS. rendertarget. settransform (matrix); CVs. pen. color: = clpurple; CVs. polygon (PTS); 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.