--- title: "How to: Draw a Line Filled with a Texture" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "drawing [Windows Forms], lines" - "lines [Windows Forms], texture" - "drawing lines [Windows Forms], texture" ms.assetid: dc9118cc-f3c2-42e5-8173-f46d41d18fd5 --- # How to: Draw a Line Filled with a Texture Instead of drawing a line with a solid color, you can draw a line with a texture. To draw lines and curves with a texture, create a object, and pass that object to a constructor. The bitmap associated with the texture brush is used to tile the plane (invisibly), and when the pen draws a line or curve, the stroke of the pen uncovers certain pixels of the tiled texture. ## Example The following example creates a object from the file `Texture1.jpg`. That bitmap is used to construct a object, and the object is used to construct a object. The call to draws the bitmap with its upper-left corner at (0, 0). The call to uses the object to draw a textured ellipse. The following illustration shows the bitmap and the textured ellipse: ![Screenshot that shows the bitmap and the textured ellipse.](./media/how-to-draw-a-line-filled-with-a-texture/bitmap-textured-ellipse.png) [!code-csharp[System.Drawing.UsingAPen#61](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Drawing.UsingAPen/CS/Class1.cs#61)] [!code-vb[System.Drawing.UsingAPen#61](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.UsingAPen/VB/Class1.vb#61)] ## Compiling the Code Create a Windows Form and handle the form's event. Paste the preceding code into the event handler. Replace `Texture.jpg` with an image valid on your system. ## See also - [Using a Pen to Draw Lines and Shapes](using-a-pen-to-draw-lines-and-shapes.md) - [Graphics and Drawing in Windows Forms](graphics-and-drawing-in-windows-forms.md)