' Make a bitmap containing the brush's text.
Using small_font As New Font("Times New Roman", 8)
' See how big the text will be.
Dim text_size As SizeF = _
e.Graphics.MeasureString("Text", small_font)
' Make a Bitmap to hold the text.
Dim bm As New Bitmap( _
CInt(2 * text_size.Width), _
CInt(2 * text_size.Height))
Using gr As Graphics = Graphics.FromImage(bm)
gr.Clear(Color.LightBlue)
gr.DrawString("Text", small_font, Brushes.Red, 0, 0)
gr.DrawString("Text", small_font, Brushes.Green, _
text_size.Width, 0)
gr.DrawString("Text", small_font, Brushes.Blue, _
-text_size.Width / 2, text_size.Height)
gr.DrawString("Text", small_font, _
Brushes.DarkOrange, text_size.Width / 2, _
text_size.Height)
gr.DrawString("Text", small_font, Brushes.Blue, _
1.5F * text_size.Width, text_size.Height)
' Fill the path with the brush.
Using br As New TextureBrush(bm)
e.Graphics.FillPath(br, path)
End Using
End Using
' Outline the path.
Using pen As New Pen(Color.Black, 3)
e.Graphics.DrawPath(pen, path)
End Using
End Using
|