ColorF class

Defines a set of constants that represents known colors and provides convenience methods for instantiating different colors.

Members

The ColorF class inherits from D2D1_COLOR_F. ColorF also has these types of members:

Constructors

The ColorF class has these constructors.

ConstructorDescription
ColorF(FLOAT, FLOAT, FLOAT, FLOAT)(FLOAT,FLOAT,FLOAT,FLOAT)

Instantiates a new instance of the ColorF class that contains the specified red, green, blue, and alpha values.

ColorF(knownColor, FLOAT)(Enum,FLOAT)

Instantiates a new instance of the ColorF class from the specified known color name and an alpha value.

ColorF(UINT32 rgb, FLOAT a)(UINT32,FLOAT)

Instantiates a new instance of the ColorF class that contains the specified RGB and alpha values.

 

Color constants

The ColorF class defines the following enumeration constants that can be used with the ColorF method to create a predefined color.

The following illustration shows a swatch of each predefined color, its knownColor name, and its hexadecimal rgb value in the #rrggbb format. The rr, gg, and bb each represent a two digit hexadecimal value used to specify the amount of red, green, and blue in the color. Each hexadecimal digit may have a value from 0-9 or A-F. 0 is the smallest value, and F is the greatest.

Illustration of the predefined colors and examples of them

Examples

The following example uses the ColorF class to specify a predefined color, black, when creating an ID2D1SolidColorBrush.


hr = m_pRenderTarget->CreateSolidColorBrush(
    D2D1::ColorF(D2D1::ColorF::Black, 1.0f),
    &m_pBlackBrush
    );


For the complete code, see the Brush Types Example.

The next example uses the ColorF class to specify a color using red, green, blue, and alpha values.


ID2D1SolidColorBrush *pGridBrush = NULL;
hr = pCompatibleRenderTarget->CreateSolidColorBrush(
    D2D1::ColorF(D2D1::ColorF(0.93f, 0.94f, 0.96f, 1.0f)),
    &pGridBrush
    );


For the complete code, see the Simple Direct2D Application Sample.

Requirements

Minimum supported client

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

Minimum supported server

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

Minimum supported phone

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

Namespace

D2D1

Header

D2d1.h

Library

D2d1.lib

DLL

D2d1.dll

See also

D2D1_COLOR_F

 

 

Community Additions

ADD
Show:
© 2014 Microsoft