この Graphics オブジェクトのクリップ領域を現在のクリップ領域と指定した Rectangle 構造体との交差部分に更新します。
Overloads Public Sub IntersectClip( _
ByVal rect As Rectangle _)
[C#]
public void IntersectClip(Rectanglerect);
[C++]
public: void IntersectClip(Rectanglerect);
[JScript]
public function IntersectClip(
rect : Rectangle);
パラメータ
- rect
現在のクリップ領域と交差する Rectangle 構造体。
戻り値
このメソッドは値を返しません。
解説
このメソッドは、現在のクリップ領域と rect パラメータで指定された四角形との交差部分によって表される領域をこの Graphics オブジェクトの Clip プロパティに割り当てます。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- 左上隅が (0, 0) に位置する四角形を作成し、この四角形にクリッピング領域を設定します。
- 左上隅が (100, 100) に位置する 2 つ目の四角形を作成し、この四角形と現在のクリッピング領域 (最初の四角形) との交差部分にクリッピング領域を設定します。
- 青いソリッド ブラシで、前の 2 つの四角形を含む大きな四角形を塗りつぶします。
- クリッピング領域を無制限にリセットします。
- 2 つのクリッピング領域の周りに四角形を描画します。最初のクリッピング四角形には黒いペンを、2 つ目のクリッピング領域には赤いペンを使用します。
[Visual Basic, C#] 2 つの四角形の交差部分だけが青く塗りつぶされます。
Public Sub IntersectClipRectangle(e As PaintEventArgs)
' Set clipping region.
Dim clipRect As New Rectangle(0, 0, 200, 200)
e.Graphics.SetClip(clipRect)
' Update clipping region to intersection of
' existing region with specified rectangle.
Dim intersectRect As New Rectangle(100, 100, 200, 200)
e.Graphics.IntersectClip(intersectRect)
' Fill rectangle to demonstrate effective clipping region.
e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
500, 500)
' Reset clipping region to infinite.
e.Graphics.ResetClip()
' Draw clipRect and intersectRect to screen.
e.Graphics.DrawRectangle(New Pen(Color.Black), clipRect)
e.Graphics.DrawRectangle(New Pen(Color.Red), intersectRect)
End Sub
[C#]
public void IntersectClipRectangle(PaintEventArgs e)
{
// Set clipping region.
Rectangle clipRect = new Rectangle(0, 0, 200, 200);
e.Graphics.SetClip(clipRect);
// Update clipping region to intersection of
// existing region with specified rectangle.
Rectangle intersectRect = new Rectangle(100, 100, 200, 200);
e.Graphics.IntersectClip(intersectRect);
// Fill rectangle to demonstrate effective clipping region.
e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 500, 500);
// Reset clipping region to infinite.
e.Graphics.ResetClip();
// Draw clipRect and intersectRect to screen.
e.Graphics.DrawRectangle(new Pen(Color.Black), clipRect);
e.Graphics.DrawRectangle(new Pen(Color.Red), intersectRect);
}
[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.IntersectClip オーバーロードの一覧