Region.Complement メソッド

定義

このRegionを、このRectangleFと交差しない指定したRegion構造体の部分に更新します。

オーバーロード

名前 説明
Complement(Region)

このRegionを更新して、このRegionと交差しない指定したRegionの部分を格納します。

Complement(RectangleF)

このRegionを更新して、このRectangleFと交差しない指定したRegion構造体の部分を格納します。

Complement(GraphicsPath)

このRegionを更新して、このGraphicsPathと交差しない指定したRegionの部分を格納します。

Complement(Rectangle)

このRegionを更新して、このRectangleと交差しない指定したRegion構造体の部分を格納します。

Complement(Region)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

このRegionを更新して、このRegionと交差しない指定したRegionの部分を格納します。

public:
 void Complement(System::Drawing::Region ^ region);
public void Complement(System.Drawing.Region region);
member this.Complement : System.Drawing.Region -> unit
Public Sub Complement (region As Region)

パラメーター

region
Region

このRegion オブジェクトを補完するRegion オブジェクト。

例外

regionnullです。

次の例は Windows フォームで使用できるように設計されており、PaintEventArgs イベント ハンドラーのパラメーターであるePaintが必要です。 コードは次のアクションを実行します。

  • 四角形を作成し、黒で画面に描画します。

  • 最初の四角形と交差する 2 つ目の四角形を作成し、赤で画面に描画します。

  • 最初の四角形を使用して 1 つの領域を作成し、2 番目の四角形を使用して 2 番目の領域を作成します。

  • 2 番目のリージョンと組み合わせた場合に、その最初のリージョンの補数を取得します。

  • 補数領域を青で塗りつぶし、画面に描画します。

最初の領域と交差しない 2 番目の領域の領域が青色に色付けされていることに注意してください。

public:
   void Complement_Region_Example( PaintEventArgs^ e )
   {
      // Create the first rectangle and draw it to the screen in black.
      Rectangle regionRect = Rectangle(20,20,100,100);
      e->Graphics->DrawRectangle( Pens::Black, regionRect );

      // Create the second rectangle and draw it to the screen in red.
      Rectangle complementRect = Rectangle(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, complementRect );

      // Create a region from the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

      // Create a complement region.
      System::Drawing::Region^ complementRegion = gcnew System::Drawing::Region( complementRect );

      // Get the complement of myRegion when combined with
      // complementRegion.
      myRegion->Complement( complementRegion );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_Region_Example(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.
    Rectangle complementRect = new Rectangle(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red, complementRect);
             
    // Create a region from the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Create a complement region.
    Region complementRegion = new Region(complementRect);
             
    // Get the complement of myRegion when combined with
             
    // complementRegion.
    myRegion.Complement(complementRegion);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_Region_Example(ByVal 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 complementRect As New Rectangle(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, complementRect)

    ' create a region from the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Create a complement region.
    Dim complementRegion As New [Region](complementRect)

    ' Get the complement of myRegion when combined with
    ' complementRegion.
    myRegion.Complement(complementRegion)

    ' Fill the complement area with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

適用対象

Complement(RectangleF)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

このRegionを更新して、このRectangleFと交差しない指定したRegion構造体の部分を格納します。

public:
 void Complement(System::Drawing::RectangleF rect);
public void Complement(System.Drawing.RectangleF rect);
member this.Complement : System.Drawing.RectangleF -> unit
Public Sub Complement (rect As RectangleF)

パラメーター

rect
RectangleF

このRectangleFを補完するRegion構造。

次のコード例は、Windows フォームで使用するように設計されており、PaintEventArgse が必要です。これは、Paint イベント ハンドラーのパラメーターです。 コードは次のアクションを実行します。

  • 四角形を作成し、黒で画面に描画します。

  • 最初の四角形と交差する 2 つ目の四角形を作成し、赤で画面に描画します。

  • 最初の四角形を使用して領域を作成します。

  • 2 番目の四角形と結合されたその領域の補数を取得します。

  • 補数領域を青で塗りつぶし、画面に描画します。

領域と交差しない 2 番目の四角形の領域が青に色付けされていることに注意してください。

public:
   void Complement_RectF_Example( PaintEventArgs^ e )
   {
      // Create the first rectangle and draw it to the screen in black.
      Rectangle regionRect = Rectangle(20,20,100,100);
      e->Graphics->DrawRectangle( Pens::Black, regionRect );

      // Create the second rectangle and draw it to the screen in red.
      RectangleF complementRect = RectangleF(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) );

      // Create a region using the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

      // Get the complement of the region combined with the second
      // rectangle.
      myRegion->Complement( complementRect );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_RectF_Example(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 complementRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(complementRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the complement of the region combined with the second
             
    // rectangle.
    myRegion.Complement(complementRect);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_RectF_Example(ByVal 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 complementRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, _
    Rectangle.Round(complementRect))

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the complement of the region combined with the second
    ' rectangle.
    myRegion.Complement(complementRect)

    ' Fill the complement area with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

適用対象

Complement(GraphicsPath)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

このRegionを更新して、このGraphicsPathと交差しない指定したRegionの部分を格納します。

public:
 void Complement(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Complement(System.Drawing.Drawing2D.GraphicsPath path);
member this.Complement : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Complement (path As GraphicsPath)

パラメーター

path
GraphicsPath

このGraphicsPathを補完するRegion

例外

pathnullです。

次のコード例は、Windows フォームで使用するように設計されており、PaintEventArgse が必要です。これは、Paint イベント ハンドラーのパラメーターです。 コードは次のアクションを実行します。

  • 四角形を作成し、黒で画面に描画します。

  • 最初の四角形と交差する 2 つ目の四角形を作成し、赤で画面に描画します。

  • 最初の四角形を使用して領域を作成します。

  • GraphicsPathを作成し、2 番目の四角形を追加します。

  • GraphicsPathと組み合わせた場合のリージョンの補数を取得します。

  • 補数領域を青で塗りつぶし、画面に描画します。

領域と交差しない GraphicsPath の領域が青色に色付けされていることに注意してください。

public:
   void Complement_Path_Example( PaintEventArgs^ e )
   {
      // Create the first rectangle and draw it to the screen in black.
      Rectangle regionRect = Rectangle(20,20,100,100);
      e->Graphics->DrawRectangle( Pens::Black, regionRect );

      // Create the second rectangle and draw it to the screen in red.
      Rectangle complementRect = Rectangle(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, complementRect );

      // Create a graphics path and add the second rectangle to it.
      GraphicsPath^ complementPath = gcnew GraphicsPath;
      complementPath->AddRectangle( complementRect );

      // Create a region using the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

      // Get the complement of myRegion when combined with
      // complementPath.
      myRegion->Complement( complementPath );

      // Fill the complement area with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Complement_Path_Example(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.
    Rectangle complementRect = new Rectangle(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red, complementRect);
             
    // Create a graphics path and add the second rectangle to it.
    GraphicsPath complementPath = new GraphicsPath();
    complementPath.AddRectangle(complementRect);
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the complement of myRegion when combined with
             
    // complementPath.
    myRegion.Complement(complementPath);
             
    // Fill the complement area with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Complement_Path_Example(ByVal 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 complementRect As New Rectangle(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, complementRect)

    ' Create a graphics path and add the second rectangle to it.
    Dim complementPath As New GraphicsPath
    complementPath.AddRectangle(complementRect)

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the complement of myRegion when combined with
    ' complementPath.
    myRegion.Complement(complementPath)

    ' Fill the complement area with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

適用対象

Complement(Rectangle)

ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs
ソース:
Region.cs

このRegionを更新して、このRectangleと交差しない指定したRegion構造体の部分を格納します。

public:
 void Complement(System::Drawing::Rectangle rect);
public void Complement(System.Drawing.Rectangle rect);
member this.Complement : System.Drawing.Rectangle -> unit
Public Sub Complement (rect As Rectangle)

パラメーター

rect
Rectangle

このRectangleを補完するRegion構造。

例については、 Complement(RectangleF) メソッドを参照してください。

適用対象