Windows apps
Collapse the table of content
Expand the table of content
Information
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.

D2D1_DASH_STYLE enumeration

Describes the sequence of dashes and gaps in a stroke.

Syntax


typedef enum  { 
  D2D1_DASH_STYLE_SOLID         = 0,
  D2D1_DASH_STYLE_DASH          = 1,
  D2D1_DASH_STYLE_DOT           = 2,
  D2D1_DASH_STYLE_DASH_DOT      = 3,
  D2D1_DASH_STYLE_DASH_DOT_DOT  = 4,
  D2D1_DASH_STYLE_CUSTOM        = 5
} D2D1_DASH_STYLE;

Constants

D2D1_DASH_STYLE_SOLID

A solid line with no breaks.

D2D1_DASH_STYLE_DASH

A dash followed by a gap of equal length. The dash and the gap are each twice as long as the stroke thickness.

The equivalent dash array for D2D1_DASH_STYLE_DASH is {2, 2}.

D2D1_DASH_STYLE_DOT

A dot followed by a longer gap.

The equivalent dash array for D2D1_DASH_STYLE_DOT is {0, 2}.

D2D1_DASH_STYLE_DASH_DOT

A dash, followed by a gap, followed by a dot, followed by another gap.

The equivalent dash array for D2D1_DASH_STYLE_DASH_DOT is {2, 2, 0, 2}.

D2D1_DASH_STYLE_DASH_DOT_DOT

A dash, followed by a gap, followed by a dot, followed by another gap, followed by another dot, followed by another gap.

The equivalent dash array for D2D1_DASH_STYLE_DASH_DOT_DOT is {2, 2, 0, 2, 0, 2}.

D2D1_DASH_STYLE_CUSTOM

The dash pattern is specified by an array of floating-point values.

Remarks

The following illustration shows several available dash styles.

Illustration of available dash styles

Examples

The following example creates a stroke that uses a custom dash pattern.


// Dash array for dashStyle D2D1_DASH_STYLE_CUSTOM
float dashes[] = {1.0f, 2.0f, 2.0f, 3.0f, 2.0f, 2.0f};

// Stroke Style with Dash Style -- Custom
if (SUCCEEDED(hr))
{
    hr = m_pD2DFactory->CreateStrokeStyle(
        D2D1::StrokeStyleProperties(
            D2D1_CAP_STYLE_FLAT,
            D2D1_CAP_STYLE_FLAT,
            D2D1_CAP_STYLE_ROUND,
            D2D1_LINE_JOIN_MITER,
            10.0f,
            D2D1_DASH_STYLE_CUSTOM,
            0.0f),
        dashes,
        ARRAYSIZE(dashes),
        &m_pStrokeStyleCustomOffsetZero
        );
}


The next example uses the stroke style when drawing a line.


m_pRenderTarget->DrawLine(
    D2D1::Point2F(0, 310),
    D2D1::Point2F(200, 310),
    m_pCornflowerBlueBrush,
    10.0f,
    m_pStrokeStyleCustomOffsetZero
    );


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]

Header

D2d1.h

 

 

Show:
© 2017 Microsoft