다음을 통해 공유


개체를 번역하는 방법

2차원 개체를 변환하려면 x축, y축 또는 둘 다를 따라 개체를 이동합니다. 다음 두 가지 방법 중 하나를 호출하여 번역 변환을 만들 수 있습니다.

다음 코드는 x축을 따라 제곱 20 단위를 오른쪽으로 이동하고 y축을 따라 아래쪽으로 10 단위를 이동하는 변환 변환 매트릭스를 만듭니다.

    // Create a rectangle.
    D2D1_RECT_F rectangle = D2D1::Rect(126.0f, 80.5f, 186.0f, 140.5f);

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

    // Apply the translation transform to the render target.
    m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(20, 10));

    // Paint the interior of the rectangle.
    m_pRenderTarget->FillRectangle(rectangle, m_pFillBrush);

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

다음 그림에서는 원래 사각형이 점선 윤곽선이고 변환된 사각형이 단색 윤곽선인 사각형에 변환 변환을 적용하는 효과를 보여 줍니다.

x축을 따라 오른쪽으로 20단위, y축을 따라 아래로 10단위 이동한 정사각형 그림

Direct2D 참조

Direct2D 변환 개요