Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
Dim txt = " VB" & vbCrLf & ".NET"
Dim font_size As Single = 64
Dim text_path As New GraphicsPath()
Dim font_family As New FontFamily("Comic Sans MS")
' Add text to the path.
text_path.AddString(txt, _
font_family, _
System.Drawing.FontStyle.Bold, _
font_size, _
New PointF(5, 5), _
System.Drawing.StringFormat.GenericDefault)
' Get the text's width and height.
Dim txt_size As SizeF = _
e.Graphics.MeasureString(txt, _
New Font(font_family, _
font_size, _
FontStyle.Bold, _
GraphicsUnit.Pixel))
' Fill the path with a gradient.
e.Graphics.FillPath( _
New System.Drawing.Drawing2D.LinearGradientBrush( _
New Point(5, 5), _
New Point(5 + txt_size.Width, 5 + _
txt_size.Height), _
Color.Red, _
Color.Blue), _
text_path)
' Outline the path.
e.Graphics.DrawPath(Pens.Black, text_path)
End Sub
|