次の方法で共有


Graphics.SetClip メソッド (GraphicsPath)

この Graphics オブジェクトのクリッピング領域を指定した GraphicsPath オブジェクトに設定します。

Overloads Public Sub SetClip( _
   ByVal path As GraphicsPath _)
[C#]
public void SetClip(GraphicsPathpath);
[C++]
public: void SetClip(GraphicsPath* path);
[JScript]
public function SetClip(
   path : GraphicsPath);

パラメータ

  • path
    新しいクリップ領域を表す GraphicsPath オブジェクト。

戻り値

このメソッドは値を返しません。

解説

path パラメータによって表されるグラフィックス パスが閉じられていない場合は、パスを閉じるために最後の点と最初の点を結ぶ線分が追加されます。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • グラフィックス パスを作成し、そのパスに楕円を追加します。
  • クリッピング領域を楕円パスに設定します。
  • 黒いソリッド ブラシで大きな四角形を塗りつぶします。

[Visual Basic, C#] 黒で塗りつぶされた楕円が生成されます。

 
Public Sub SetClipPath(e As PaintEventArgs)
' Create graphics path.
Dim clipPath As New GraphicsPath()
clipPath.AddEllipse(0, 0, 200, 100)
' Set clipping region to path.
e.Graphics.SetClip(clipPath)
' Fill rectangle to demonstrate clipping region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
End Sub
        
[C#] 
public void SetClipPath(PaintEventArgs e)
{
// Create graphics path.
GraphicsPath clipPath = new GraphicsPath();
clipPath.AddEllipse(0, 0, 200, 100);
// Set clipping region to path.
e.Graphics.SetClip(clipPath);
// Fill rectangle to demonstrate clipping region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.SetClip オーバーロードの一覧