共用方式為


如何:以規劃圖樣填滿形狀

影線圖樣由兩種色彩組成:一種用於背景,另一個用於在背景上形成圖案的線條。 若要以影線圖樣填滿封閉圖案,請使用 HatchBrush 物件。 下列範例示範如何使用影線圖樣填滿橢圓形:

範例

HatchBrush 構函式會採用三個引數:影線樣式、影線的色彩,以及背景的色彩。 影線樣式引數可以是列舉中的任何值 HatchStyle 。 列舉中有 HatchStyle 五十多個元素;下列清單中顯示其中一些元素:

下圖顯示填滿橢圓形。

Screenshot of what an ellipse filled with a hatch pattern looks like.

HatchBrush hBrush = new HatchBrush(
   HatchStyle.Horizontal,
   Color.Red,
   Color.FromArgb(255, 128, 255, 255));
e.Graphics.FillEllipse(hBrush, 0, 0, 100, 60);
Dim hBrush As New HatchBrush( _
   HatchStyle.Horizontal, _
   Color.Red, _
   Color.FromArgb(255, 128, 255, 255))
e.Graphics.FillEllipse(hBrush, 0, 0, 100, 60)

編譯程式碼

上述範例是為了搭配 Windows Form 使用而設計,且其需要 PaintEventArgse,這是 Paint 事件處理常式的參數。

另請參閱