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