ID2D1RenderTarget::DrawLine method

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.
This topic has not yet been rated - Rate this topic

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

A value greater than or equal to 0.0f that specifies the width of the stroke. 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
                );
        }


For the complete code, see the Draw Rectangle Example.

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]

Header

D2d1.h

Library

D2d1.lib

DLL

D2d1.dll

See also

ID2D1RenderTarget

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

© 2013 Microsoft. All rights reserved.