Transparent Brush : SolidBrush « 2D Graphics « VB.Net Tutorial






Transparent Brush
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class AlphaBPensBrushes
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

public class Form1
  Inherits System.Windows.Forms.Form

  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)

        Dim rect As New Rectangle(220, 30, 100, 50)
        Dim transPen As New Pen(Color.FromArgb(128, 255, 255, 255), 10)
        Dim totTransPen As New Pen(Color.FromArgb(40, 0, 255, 0), 10)
        g.DrawLine(transPen, 10, 30, 200, 30)
        g.DrawLine(totTransPen, 10, 50, 200, 50)
        g.FillRectangle(New SolidBrush(Color.FromArgb(40, 0, 0, 255)), rect)
        rect.Y += 60
        g.FillEllipse(New SolidBrush(Color.FromArgb(20, 255, 255, 0)), rect)
        Dim semiTransBrush As New SolidBrush(Color.FromArgb(90, 0, 50, 255))
        g.DrawString("String " + ControlChars.Lf + "Date: ", New Font("Verdana", 14), semiTransBrush, New RectangleF(20, 100, 300, 100))


        g.Dispose()


  End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

  End Sub

End Class








17.64.SolidBrush
17.64.1.Create Brush with ColorCreate Brush with Color
17.64.2.Draw string with Brushes.Maroon
17.64.3.Color BrushesColor Brushes
17.64.4.Transparent BrushTransparent Brush