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 aobject, and pass that TextureBrush 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.
The following example creates aobject from the file Texture1.jpg. That bitmap is used to construct a TextureBrush object, and the TextureBrush 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 Pen object to draw a textured ellipse.
The following illustration shows the bitmap and the textured ellipse.
Compiling the Code
Create a Windows Form and handle the form'sevent. Paste the preceding code into the Paint event handler. Replace Texture.jpg with an image valid on your system.