Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Mengecat interior persegi panjang yang ditentukan.
Daftar kelebihan beban
| Metode | Deskripsi |
|---|---|
| FillRectangle(D2D1_RECT_F&,ID2D1Brush*) | Mengecat interior persegi panjang yang ditentukan. |
| FillRectangle(D2D1_RECT_F*,ID2D1Brush*) | Mengecat interior persegi panjang yang ditentukan. |
Keterangan
Metode ini tidak mengembalikan kode kesalahan jika gagal. Untuk menentukan apakah operasi gambar (seperti FillRectangle) gagal, periksa hasil yang dikembalikan oleh metode ID2D1RenderTarget::EndDraw atau ID2D1RenderTarget::Flush.
Contoh
Contoh berikut menggunakan ID2D1HwndRenderTarget untuk menggambar dan mengisi beberapa persegi panjang. Contoh ini menghasilkan output yang ditunjukkan dalam ilustrasi berikut.

// 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(&rectangle1, m_pLightSlateGrayBrush);
// Draw the outline of a rectangle.
m_pRenderTarget->DrawRectangle(&rectangle2, m_pCornflowerBlueBrush);
hr = m_pRenderTarget->EndDraw();
}
if (hr == D2DERR_RECREATE_TARGET)
{
hr = S_OK;
DiscardDeviceResources();
}
return hr;
}
Untuk tutorial terkait, lihat Membuat aplikasi Direct2D sederhana.
Persyaratan
| Persyaratan | Value |
|---|---|
| Header |
|
| Pustaka |
|
| DLL |
|
Baca juga
�
�