次の方法で共有


Region.Xor メソッド (RectangleF)

この Region オブジェクトを、そのオブジェクトと指定の RectangleF 構造体の交差部分を差し引いた和集合に更新します。

Overloads Public Sub Xor( _
   ByVal rect As RectangleF _)
[C#]
public void Xor(RectangleFrect);
[C++]
public: void Xor(RectangleFrect);
[JScript]
public function Xor(
   rect : RectangleF);

パラメータ

  • rect
    この Region オブジェクトと XOR 演算する RectangleF 構造体。

戻り値

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

使用例

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

  • 最初の四角形を作成し、黒で画面に描画します。
  • 2 番目の四角形を作成し、赤で画面に描画します。
  • 最初の四角形を使用して領域を作成します。
  • complementRect と組み合わせたときの myRegion の Xor 部分を取得します。
  • 青で Xor 部分を塗りつぶし、画面に描画します。

[Visual Basic, C#] 両方の四角形が、重複部分を除いて青で塗りつぶされます。

 
Public Sub XorExample(e As PaintEventArgs)
' Create the first rectangle and draw it to the screen in black.
Dim regionRect As New Rectangle(20, 20, 100, 100)
e.Graphics.DrawRectangle(Pens.Black, regionRect)
' create the second rectangle and draw it to the screen in red.
Dim xorRect As New RectangleF(90, 30, 100, 100)
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(xorRect))
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Get the area of overlap for myRegion when combined with
' complementRect.
myRegion.Xor(xorRect)
' Fill the intersection area of myRegion with blue.
Dim myBrush As New SolidBrush(Color.Blue)
e.Graphics.FillRegion(myBrush, myRegion)
End Sub
        
[C#] 
public void XorExample(PaintEventArgs e)
{
// Create the first rectangle and draw it to the screen in black.
Rectangle regionRect = new Rectangle(20, 20, 100, 100);
e.Graphics.DrawRectangle(Pens.Black, regionRect);
// create the second rectangle and draw it to the screen in red.
RectangleF xorRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red,
Rectangle.Round(xorRect));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Get the area of overlap for myRegion when combined with
// complementRect.
myRegion.Xor(xorRect);
// Fill the Xor area of myRegion with blue.
SolidBrush myBrush = new SolidBrush(Color.Blue);
e.Graphics.FillRegion(myBrush, myRegion);
}
        

[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 ファミリ

参照

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