Create a brush

oka

New member
Joined
Jul 14, 2006
Messages
3
Programming Experience
Beginner
VB.NET:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim redBrush As New Drawing.SolidBrush(Color.Red)
        Dim confettiBrush As New Drawing2D.HatchBrush( _
        Drawing2D.HatchStyle.LargeConfetti, Color.White, _
        Color.Blue)
        Dim myGradientRect As New _
        Drawing.Rectangle(5, 110, 100, 100)

        Dim gradient As New Drawing2D.LinearGradientBrush(myGradientRect, Color.Cyan, Color.Yellow, 45)
        e.Graphics.FillRectangle(redBrush, 5, 5, 100, 100)
        e.Graphics.FillRectangle(confettiBrush, 110, 5, 100, 100)
        e.Graphics.FillRectangle(gradient, 5, 110, 100, 100)
    End Sub
End Class
What does the line

VB.NET:
Dim myGradientRect As New _
        Drawing.Rectangle(5, 110, 100, 100)
I mean what is the significance of 5,110, 100, 100?
 
In a nutshell, it tells the system to draw a rectangle at a specific locaiton:
Starting at x,y co-ordinates 5, 110, draw a rectangle 100 pixels high by 100 pixels wide (a square esentialy)

-tg
 
Just to add a bit, remember computers are stupid, you need to tell them to do everything. If you want to draw anything on a 2-dimensional plane you have to tell it where to draw it which are the x,y argument and then how big you want it, the last two arguments.
 
oka, just wondering if you are using Visual Studio to write your code (I assume this is code you got from somewhere else, so the question is are you using Visual Studio to create the app.)
If so you can place the cursor in a word in your code and by pressing F2 the object browser will open to that class/method/whatever. Fressing F1 will open help to that class/method/whatever. This way you can get more information regarding that class/method/whatever.
 
Back
Top