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.

ID2D1RenderTarget::DrawLine method

Draws a line between the specified points using the specified stroke style.

Syntax


virtual void DrawLine(
                 D2D1_POINT_2F    point0,
                 D2D1_POINT_2F    point1,
  [in]           ID2D1Brush       *brush,
                 FLOAT            strokeWidth = 1.0f,
  [in, optional] ID2D1StrokeStyle *strokeStyle = NULL
) = 0;

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.

brush [in]

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.

strokeStyle [in, optional]

Type: ID2D1StrokeStyle*

The style of stroke to paint, or NULL to paint a solid line.

Return value

This method does not return a value.

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

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]

Header

D2d1.h

Library

D2d1.lib

DLL

D2d1.dll

See also

ID2D1RenderTarget

 

 

Show:
© 2018 Microsoft