Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleUse a TextureBrush in VB .NET
Keywordsbrush, texturebrush, VB.NET
CategoriesGraphics, VB.NET
 
This program creates an array of points to define a polygon. It calls its Graphics object's FillPolygon method to fill the polygon. It uses a TextureBrush object that takes its texture from the image stored in the picFace PictureBox. This tiles the polygon with the image.

The program then creates a Pen with color tomato and three pixels wide. It sets the Pen's DashStyle to Dash and calls the Graphics object's DrawPolygon method to outline the polygon.

 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim pts() As Point = { _
        New Point(20, 5), _
        New Point(100, 30), _
        New Point(80, 100), _
        New Point(120, 120), _
        New Point(60, 140), _
        New Point(5, 60) _
    }

    ' Fill a polygon with a textured brush.
    e.Graphics.FillPolygon( _
        New TextureBrush(picFace.Image), pts)

    ' Make a pen.
    Dim a_pen As New Pen(Color.Tomato, 3)
    a_pen.DashStyle = Drawing.Drawing2D.DashStyle.Dash

    ' Outline the polygon.
    e.Graphics.DrawPolygon(a_pen, pts)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated