Matrix3x2F::Rotation 方法 (d2d1helper.h)

建立具有指定角度和中心點的旋轉轉換。

語法

Matrix3x2F Rotation(
  FLOAT         angle,
  D2D1_POINT_2F center
);

參數

angle

類型: FLOAT

旋轉角度以度為單位。 正角度會建立順時針旋轉,負角度會建立反時針旋轉。

center

類型: D2D1_POINT_2F

執行旋轉的點。

傳回值

類型: Matrix3x2F

新的旋轉轉換。

備註

呼叫此方法時,請指定 centerPoint 以繞著旋轉物件,並以度為單位旋轉 角度 。 下圖顯示其中心點的方形旋轉 45 度。

圖例原始方形中央的正方形旋轉順時針 45 度

範例

下列範例會使用 D2D1::Matrix3x2F::Rotation 方法建立旋轉矩陣,以四四五度旋轉正方形的中央,並將矩陣傳遞至轉譯目標 (m_pRenderTarget) 的 SetTransform 方法。

下圖顯示將上述旋轉轉換套用至平方的效果。 原始方形是虛線外框,旋轉的方形是實心外框。

圖例正方形旋轉 45 度,與原始方形的中心有關
    // 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);


此範例中已省略程序代碼。 如需轉換的詳細資訊,請參閱 轉換概觀

規格需求

需求
最低支援的用戶端 適用於 Windows Vista 的 Windows 7、Windows Vista SP2 和平臺更新 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 d2d1helper.h
程式庫 D2d1.lib
Dll D2d1.dll

另請參閱

Matrix3x2F