Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID2D1SolidColorBrush interface

Paints an area with a solid color.

When to implement

Custom implementations are not supported.


The ID2D1SolidColorBrush interface inherits from ID2D1Brush. ID2D1SolidColorBrush also has these types of members:


The ID2D1SolidColorBrush interface has these methods.


Retrieves the color of the solid color brush.

SetColor Overloaded.

Specifies the color of this solid color brush.



Creating ID2D1SolidColorBrush Objects

To create a solid color brush, use the ID2D1RenderTarget::CreateSolidColorBrush method of the render target on which the brush will be used. The brush can only be used with the render target that created it or with the compatible targets for that render target.

A solid color brush is a device-dependent resource. (For more information about resources, see Resources Overview.)


The following example uses the CreateSolidColorBrush method of a render target (m_pRenderTarget) to create two brushes. The example uses a predefined color (black) to specify the color of the first brush. It uses a hexadecimal color value (yellow) to specify the color of the second brush.

if (SUCCEEDED(hr))
    hr = m_pRenderTarget->CreateSolidColorBrush(
        D2D1::ColorF(D2D1::ColorF::Black, 1.0f),

// Create a solid color brush with its rgb value 0x9ACD32.
if (SUCCEEDED(hr))
    hr = m_pRenderTarget->CreateSolidColorBrush(
        D2D1::ColorF(D2D1::ColorF(0x9ACD32, 1.0f)),  

The next code example calls the FillRectangle method to paint the interior of a rectangle with the yellow green brush and the DrawRectangle method to paint the outline of the rectangle with the black brush:

m_pRenderTarget->FillRectangle(&rcBrushRect, m_pYellowGreenBrush);
m_pRenderTarget->DrawRectangle(&rcBrushRect, m_pBlackBrush, 1, NULL);

These examples produce the output shown in the following illustration.

Illustration of a rectangle filled with a solid, yellow-green color


Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]







See also

How to Create a Solid Color Brush
Brushes Overview



© 2018 Microsoft