ID2D1RenderTarget::FillRoundedRectangle メソッド
指定された角丸四角形の内部を描画します。
構文
void FillRoundedRectangle(
[ref] const D2D1_ROUNDED_RECT &roundedRect,
[in] ID2D1Brush *brush
);
パラメーター
- roundedRect
D2D1_ROUNDED_RECT 描画する角丸四角形の寸法 (デバイス非依存のピクセル単位)。 - brush [in]
ID2D1Brush 角丸四角形の内部の描画に使用するブラシ。
戻り値
This は値を返しません。
解説
このメソッドは失敗した場合でも、エラー コードが返されません。描画操作 (FillRoundedRectangle など) が失敗したかどうかを判断するには、ID2D1RenderTarget::EndDraw メソッドまたは ID2D1RenderTarget::Flush メソッドによって返された結果を確認します。
例
次の例では、DrawRoundedRectangle メソッドと FillRoundedRectangle メソッドを使用して、角丸四角形の輪郭の描画と塗りつぶしを行います。この例では、次の出力が生成されます。
// Called whenever the application needs to display the client
// window.
HRESULT DrawAndFillRoundedRectangleExample::OnRender()
{
HRESULT hr;
// Create the render target and brushes if they
// don't already exists.
hr = CreateDeviceResources();
if (SUCCEEDED(hr))
{
// Retrieve the size of the render target.
D2D1_SIZE_F renderTargetSize = m_pRenderTarget->GetSize();
m_pRenderTarget->BeginDraw();
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());
m_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White));
// Paint a grid background.
m_pRenderTarget->FillRectangle(
D2D1::RectF(0.0f, 0.0f, renderTargetSize.width, renderTargetSize.height),
m_pGridPatternBitmapBrush
);
// Define a rounded rectangle.
D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect(
D2D1::RectF(20.f, 20.f, 150.f, 100.f),
10.f,
10.f
);
// Draw the rectangle.
m_pRenderTarget->DrawRoundedRectangle(roundedRect, m_pBlackBrush, 10.f);
// Apply a translation transform.
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(200.f, 0.f));
// Draw the rounded rectangle again, this time with a dashed stroke.
m_pRenderTarget->DrawRoundedRectangle(roundedRect, m_pBlackBrush, 10.f, m_pStrokeStyle);
// Apply another translation transform.
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(0.f, 150.f));
// Draw, then fill the rounded rectangle.
m_pRenderTarget->DrawRoundedRectangle(roundedRect, m_pBlackBrush, 10.f, m_pStrokeStyle);
m_pRenderTarget->FillRoundedRectangle(roundedRect, m_pSilverBrush);
// Apply another translation transform.
m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Translation(200.f, 150.f));
// Fill, then draw the rounded rectangle.
m_pRenderTarget->FillRoundedRectangle(roundedRect, m_pSilverBrush);
m_pRenderTarget->DrawRoundedRectangle(roundedRect, m_pBlackBrush, 10.f, m_pStrokeStyle);
hr = m_pRenderTarget->EndDraw();
if (hr == D2DERR_RECREATE_TARGET)
{
hr = S_OK;
DiscardDeviceResources();
}
}
return hr;
}
完全なコードについては、「レンダー ターゲットの例」を参照してください。
要件
クライアントの最小要件 |
Windows 7, Windows Vista SP2 および Windows Vista 用のプラットフォーム更新プログラム |
サーバーの最小要件 |
Windows Server 2008 R2, Windows Server 2008 SP2 および Windows Server 2008 用のプラットフォーム更新プログラム |
ヘッダー |
D2d1.h |
ライブラリ |
D2d1.lib |
DLL |
D2d1.dll |