填充形状

Graphics.FillShapes 绘制一个形状并用给定的颜色填充它。填充形状可以使用

  1. Brush 工具 - 用纯色填充形状

    Dim rect As New Rectangle(50, 50, 50, 50)
    e.Graphics.FillRectangle(Brushes.Green, rect) 'draws a rectangle that is filled with green
    
    e.Graphics.FillPie(Brushes.Silver, rect, 0, 180) 'draws a half circle that is filled with silver
    
  2. HatchBrush 工具 - 用图案填充形状

Dim hBrush As New HatchBrush(HatchStyle.ZigZag, Color.SkyBlue, Color.Gray)
'creates a HatchBrush Tool with a background color of blue, foreground color of gray, 
'and will fill with a zigzag pattern
Dim rectan As New Rectangle(100, 100, 100, 100)
e.Graphics.FillRectangle(hBrush, rectan)
  1. LinearGradientBrush - 用渐变填充形状

    Dim lBrush As New LinearGradientBrush(point1, point2, Color.MediumVioletRed, Color.PaleGreen)
     Dim rect As New Rectangle(50, 50, 200, 200)
     e.Graphics.FillRectangle(lBrush, rect)
    
  2. TextureBrush - 用图片填充形状

你可以从资源,已定义的位图或文件名中选择图片

   Dim textBrush As New TextureBrush(New Bitmap("C:\ColorPic.jpg"))
    Dim rect As New Rectangle(400, 400, 100, 100)
    e.Graphics.FillPie(textBrush, rect, 0, 360)

Hatch Brush ToolLinearGradientBrush 都导入以下语句: Imports System.Drawing.Drawing2D