用ID2D1StrokeStyle可以构建出我们想要的风格:
virtual HRESULT CreateStrokeStyle(
[in] const D2D1_STROKE_STYLE_PROPERTIES *strokeStyleProperties,
[in, optional] const FLOAT *dashes,
UINT dashesCount,
[out] ID2D1StrokeStyle **strokeStyle
) = 0;
D2D1_STROKE_STYLE_PROPERTIES结构体中描述了中分风格;
struct D2D1_STROKE_STYLE_PROPERTIES {
D2D1_CAP_STYLE startCap;
D2D1_CAP_STYLE endCap;
D2D1_CAP_STYLE dashCap;
D2D1_LINE_JOIN lineJoin;
FLOAT miterLimit;
D2D1_DASH_STYLE dashStyle;
FLOAT dashOffset;
};
typedef enum {
D2D1_CAP_STYLE_FLAT = 0,
D2D1_CAP_STYLE_SQUARE = 1,
D2D1_CAP_STYLE_ROUND = 2,
D2D1_CAP_STYLE_TRIANGLE = 3
} D2D1_CAP_STYLE;
代码:
float dashes[] = {2.0f, 2.0f, 0.0f, 2.0f, 2.0f, 2.0f};
DX::ThrowIfFailed(
d2dFactory->CreateStrokeStyle(
D2D1::StrokeStyleProperties(
D2D1_CAP_STYLE_TRIANGLE,
D2D1_CAP_STYLE_ROUND,
D2D1_CAP_STYLE_ROUND,
D2D1_LINE_JOIN_MITER,
1.0f,
D2D1_DASH_STYLE_SOLID,
10.0f),
NULL,
0,
&pStrokeStyle
)
);
效果:
只要参考上面的步骤,以及msdn 上面的描述,即可构建出想要的中分风格
Direct2D 交流群254876370