填充形狀

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