ID2D1RenderTarget::FillRectangle 메서드

지정된 사각형의 내부를 그림판.

오버로드 목록

메서드 설명
FillRectangle(D2D1_RECT_F&,ID2D1Brush*) 지정된 사각형의 내부를 그림판.
FillRectangle(D2D1_RECT_F*,ID2D1Brush*) 지정된 사각형의 내부를 그림판.

설명

이 메서드는 실패할 경우 오류 코드를 반환하지 않습니다. 그리기 작업(예: FillRectangle)이 실패했는지 여부를 확인하려면 ID2D1RenderTarget::EndDraw 또는 ID2D1RenderTarget::Flush 메서드에서 반환된 결과를 검사.

예제

다음 예제에서는 ID2D1HwndRenderTarget을 사용하여 여러 사각형을 그리고 채웁니다. 이 예제에서는 다음 그림에 표시된 출력을 생성합니다.

illustration of two rectangles on a grid background

// This method discards device-specific
// resources if the Direct3D device dissapears during execution and
// recreates the resources the next time it's invoked.
HRESULT DemoApp::OnRender()
{
    HRESULT hr = S_OK;

    hr = CreateDeviceResources();

    if (SUCCEEDED(hr))
    {
        m_pRenderTarget->BeginDraw();

        m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());

        m_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White));

        D2D1_SIZE_F rtSize = m_pRenderTarget->GetSize();

        // Draw a grid background.
        int width = static_cast<int>(rtSize.width);
        int height = static_cast<int>(rtSize.height);

        for (int x = 0; x < width; x += 10)
        {
            m_pRenderTarget->DrawLine(
                D2D1::Point2F(static_cast<FLOAT>(x), 0.0f),
                D2D1::Point2F(static_cast<FLOAT>(x), rtSize.height),
                m_pLightSlateGrayBrush,
                0.5f
                );
        }

        for (int y = 0; y < height; y += 10)
        {
            m_pRenderTarget->DrawLine(
                D2D1::Point2F(0.0f, static_cast<FLOAT>(y)),
                D2D1::Point2F(rtSize.width, static_cast<FLOAT>(y)),
                m_pLightSlateGrayBrush,
                0.5f
                );
        }

        // Draw two rectangles.
        D2D1_RECT_F rectangle1 = D2D1::RectF(
            rtSize.width/2 - 50.0f,
            rtSize.height/2 - 50.0f,
            rtSize.width/2 + 50.0f,
            rtSize.height/2 + 50.0f
            );

        D2D1_RECT_F rectangle2 = D2D1::RectF(
            rtSize.width/2 - 100.0f,
            rtSize.height/2 - 100.0f,
            rtSize.width/2 + 100.0f,
            rtSize.height/2 + 100.0f
            );


        // Draw a filled rectangle.
        m_pRenderTarget->FillRectangle(&amp;rectangle1, m_pLightSlateGrayBrush);

        // Draw the outline of a rectangle.
        m_pRenderTarget->DrawRectangle(&amp;rectangle2, m_pCornflowerBlueBrush);

        hr = m_pRenderTarget->EndDraw();
    }

    if (hr == D2DERR_RECREATE_TARGET)
    {
        hr = S_OK;
        DiscardDeviceResources();
    }

    return hr;
}

관련 자습서는 간단한 Direct2D 애플리케이션 만들기를 참조 하세요.

요구 사항

요구 사항
헤더
D2d1_1.h(D2d1.h 포함)
라이브러리
D2d1.lib
DLL
D2d1.dll

참고 항목

ID2D1RenderTarget

간단한 Direct2D 애플리케이션 만들기