Matrix3x2F::Rotation method (d2d1helper.h)

Creates a rotation transformation that has the specified angle and center point.

Syntax

Matrix3x2F Rotation(
  FLOAT         angle,
  D2D1_POINT_2F center
);

Parameters

angle

Type: FLOAT

The rotation angle in degrees. A positive angle creates a clockwise rotation, and a negative angle creates a counterclockwise rotation.

center

Type: D2D1_POINT_2F

The point about which the rotation is performed.

Return value

Type: Matrix3x2F

The new rotation transformation.

Remarks

When calling this method, specify a centerPoint to rotate the object about, and the rotation angle in degrees. The following illustration shows a square rotated 45 degrees about its center point.

Illustration a square rotated clockwise 45 degrees about the center of the original square

Examples

The following example uses the D2D1::Matrix3x2F::Rotation method to create a rotation matrix that rotates a square clockwise 45 degrees about the center of the square and passes the matrix to the SetTransform method of the render target (m_pRenderTarget).

The following illustration shows the effect of applying the preceding rotation transformation to the square. The original square is a dotted outline, and the rotated square is a solid outline.

Illustration a square rotated 45 degrees about the center of the original square
    // Create a rectangle.
    D2D1_RECT_F rectangle = D2D1::Rect(438.0f, 301.5f, 498.0f, 361.5f);

    // Draw the rectangle.
    m_pRenderTarget->DrawRectangle(
        rectangle,
        m_pOriginalShapeBrush,
        1.0f,
        m_pStrokeStyleDash
        );

    // Apply the rotation transform to the render target.
    m_pRenderTarget->SetTransform(
        D2D1::Matrix3x2F::Rotation(
            45.0f,
            D2D1::Point2F(468.0f, 331.5f))
        );

    // Fill the rectangle.
    m_pRenderTarget->FillRectangle(rectangle, m_pFillBrush);

    // Draw the transformed rectangle.
    m_pRenderTarget->DrawRectangle(rectangle, m_pTransformedShapeBrush);


Code has been omitted from this example. For more information about transforms, see the Transforms Overview.

Requirements

Requirement Value
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header d2d1helper.h
Library D2d1.lib
DLL D2d1.dll

See also

Matrix3x2F