Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Draws a line between the specified points using the specified stroke style.
Syntax
void DrawLine(
D2D1_POINT_2F point0,
D2D1_POINT_2F point1,
[in] ID2D1Brush *brush,
FLOAT strokeWidth,
[in, optional] ID2D1StrokeStyle *strokeStyle
);
Parameters
point0
Type: D2D1_POINT_2F
The start point of the line, in device-independent pixels.
point1
Type: D2D1_POINT_2F
The end point of the line, in device-independent pixels.
[in] brush
Type: ID2D1Brush*
The brush used to paint the line's stroke.
strokeWidth
Type: FLOAT
The width of the stroke, in device-independent pixels. The value must be greater than or equal to 0.0f. If this parameter isn't specified, it defaults to 1.0f. The stroke is centered on the line.
[in, optional] strokeStyle
Type: ID2D1StrokeStyle*
The style of stroke to paint, or NULL to paint a solid line.
Return value
None
Remarks
This method doesn't return an error code if it fails. To determine whether a drawing operation (such as DrawLine) failed, check the result returned by the ID2D1RenderTarget::EndDraw or ID2D1RenderTarget::Flush methods.
Examples
The following example uses the DrawLine method to create a grid that spans the width and height of the render target. The width and height information is provided by the rtSize variable.
// Draw a grid background.
int width = static_cast<int>(rtSize.width);
int height = static_cast<int>(rtSize.height);
for (int x = 0; x < width; x += 10)
{
m_pRenderTarget->DrawLine(
D2D1::Point2F(static_cast<FLOAT>(x), 0.0f),
D2D1::Point2F(static_cast<FLOAT>(x), rtSize.height),
m_pLightSlateGrayBrush,
0.5f
);
}
for (int y = 0; y < height; y += 10)
{
m_pRenderTarget->DrawLine(
D2D1::Point2F(0.0f, static_cast<FLOAT>(y)),
D2D1::Point2F(rtSize.width, static_cast<FLOAT>(y)),
m_pLightSlateGrayBrush,
0.5f
);
}
Requirements
| Requirement | Value |
|---|---|
| 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] |
| Target Platform | Windows |
| Header | d2d1.h |
| Library | D2d1.lib |
| DLL | D2d1.dll |