次の方法で共有


Graphics.SetClip メソッド

定義

この Graphics のクリッピング領域を、指定した GraphicsClip プロパティに設定します。

オーバーロード

SetClip(Region, CombineMode)

この Graphics のクリッピング領域を、現在のクリップ領域と指定した Regionを組み合わせた指定した操作の結果に設定します。

SetClip(RectangleF, CombineMode)

この Graphics のクリッピング領域を、現在のクリップ領域と RectangleF 構造体で指定された四角形を組み合わせた指定した操作の結果に設定します。

SetClip(Rectangle, CombineMode)

この Graphics のクリッピング領域を、現在のクリップ領域と Rectangle 構造体で指定された四角形を組み合わせた指定した操作の結果に設定します。

SetClip(Graphics, CombineMode)

この Graphics のクリッピング領域を、現在のクリップ領域の指定した結合操作の結果と、指定した GraphicsClip プロパティに設定します。

SetClip(RectangleF)

この Graphics のクリッピング領域を、RectangleF 構造体で指定された四角形に設定します。

SetClip(Rectangle)

この Graphics のクリッピング領域を、Rectangle 構造体で指定された四角形に設定します。

SetClip(Graphics)

この Graphics のクリッピング領域を、指定した GraphicsClip プロパティに設定します。

SetClip(GraphicsPath)

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

SetClip(GraphicsPath, CombineMode)

この Graphics のクリッピング領域を、現在のクリップ領域と指定した GraphicsPathを組み合わせた指定した操作の結果に設定します。

SetClip(Region, CombineMode)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、現在のクリップ領域と指定した Regionを組み合わせた指定した操作の結果に設定します。

public:
 void SetClip(System::Drawing::Region ^ region, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Region region, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Region * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (region As Region, combineMode As CombineMode)

パラメーター

region
Region

結合する Region

combineMode
CombineMode

使用する結合操作を指定する CombineMode 列挙体のメンバー。

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

  • クリッピング領域の小さな四角形を作成します。

  • クリッピング領域を、Replace メンバーを持つ四角形に設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い四角形になります。

public:
   void SetClipRegionCombine( PaintEventArgs^ e )
   {
      // Create region for clipping.
      System::Drawing::Region^ clipRegion = gcnew System::Drawing::Region( Rectangle(0,0,100,100) );

      // Set clipping region of graphics to region.
      e->Graphics->SetClip( clipRegion, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRegionCombine(PaintEventArgs e)
{

    // Create region for clipping.
    Region clipRegion = new Region(new Rectangle(0, 0, 100, 100));

    // Set clipping region of graphics to region.
    e.Graphics.SetClip(clipRegion, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRegionCombine(ByVal e As PaintEventArgs)

    ' Create region for clipping.
    Dim clipRegion As New [Region](New Rectangle(0, 0, 100, 100))

    ' Set clipping region of graphics to region.
    e.Graphics.SetClip(clipRegion, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用対象

SetClip(RectangleF, CombineMode)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、現在のクリップ領域と RectangleF 構造体で指定された四角形を組み合わせた指定した操作の結果に設定します。

public:
 void SetClip(System::Drawing::RectangleF rect, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.RectangleF rect, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.RectangleF * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (rect As RectangleF, combineMode As CombineMode)

パラメーター

rect
RectangleF

結合する RectangleF 構造体。

combineMode
CombineMode

使用する結合操作を指定する CombineMode 列挙体のメンバー。

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

  • クリッピング領域の小さな四角形を作成します。

  • クリッピング領域を、Replace メンバーを持つ四角形に設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い四角形になります。

public:
   void SetClipRectangleFCombine( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleFCombine(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleFCombine(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用対象

SetClip(Rectangle, CombineMode)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、現在のクリップ領域と Rectangle 構造体で指定された四角形を組み合わせた指定した操作の結果に設定します。

public:
 void SetClip(System::Drawing::Rectangle rect, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Rectangle rect, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Rectangle * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (rect As Rectangle, combineMode As CombineMode)

パラメーター

rect
Rectangle

結合する Rectangle 構造体。

combineMode
CombineMode

使用する結合操作を指定する CombineMode 列挙体のメンバー。

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

  • クリッピング領域の小さな四角形を作成します。

  • クリッピング領域を、Replace メンバーを持つ四角形に設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い四角形になります。

public:
   void SetClipRectangleCombine( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      Rectangle clipRect = Rectangle(0,0,100,100);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleCombine(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 100, 100);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleCombine(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New Rectangle(0, 0, 100, 100)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用対象

SetClip(Graphics, CombineMode)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、現在のクリップ領域の指定した結合操作の結果と、指定した GraphicsClip プロパティに設定します。

public:
 void SetClip(System::Drawing::Graphics ^ g, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Graphics g, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Graphics * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (g As Graphics, combineMode As CombineMode)

パラメーター

g
Graphics

結合するクリップ領域を指定する Graphics

combineMode
CombineMode

使用する結合操作を指定する CombineMode 列挙体のメンバー。

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

  • 例の thisFormForm から一時的な Graphics を作成します。

  • 一時的な Graphics のクリッピング領域を小さな四角形に設定します。

  • フォームのグラフィック オブジェクトのクリッピング領域を、Replace メンバーを持つ新しい Graphics の領域に更新します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い正方形になります。

public:
   void SetClipGraphicsCombine( PaintEventArgs^ e )
   {
      // Create temporary graphics object and set its clipping region.
      Graphics^ newGraphics = this->CreateGraphics();
      newGraphics->SetClip( Rectangle(0,0,100,100) );

      // Update clipping region of graphics to clipping region of new
      // graphics.
      e->Graphics->SetClip( newGraphics, CombineMode::Replace );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );

      // Release new graphics.
      delete newGraphics;
   }
private void SetClipGraphicsCombine(PaintEventArgs e)
{

    // Create temporary graphics object and set its clipping region.
    Graphics newGraphics = this.CreateGraphics();
    newGraphics.SetClip(new Rectangle(0, 0, 100, 100));

    // Update clipping region of graphics to clipping region of new

    // graphics.
    e.Graphics.SetClip(newGraphics, CombineMode.Replace);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);

    // Release new graphics.
    newGraphics.Dispose();
}
Private Sub SetClipGraphicsCombine(ByVal e As PaintEventArgs)

    ' Create temporary graphics object and set its clipping region.
    Dim newGraphics As Graphics = Me.CreateGraphics()
    newGraphics.SetClip(New Rectangle(0, 0, 100, 100))

    ' Update clipping region of graphics to clipping region of new

    ' graphics.
    e.Graphics.SetClip(newGraphics, CombineMode.Replace)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)

    ' Release new graphics.
    newGraphics.Dispose()
End Sub

適用対象

SetClip(RectangleF)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、RectangleF 構造体で指定された四角形に設定します。

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

パラメーター

rect
RectangleF

RectangleF 新しいクリップ領域を表す構造体です。

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

  • クリッピング領域の小さな四角形を作成します。

  • クリッピング領域を四角形に設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い四角形になります。

public:
   void SetClipRectangleF( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangleF(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangleF(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用対象

SetClip(Rectangle)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、Rectangle 構造体で指定された四角形に設定します。

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

パラメーター

rect
Rectangle

Rectangle 新しいクリップ領域を表す構造体です。

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

  • クリッピング領域の小さな四角形を作成します。

  • クリッピング領域を四角形に設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い四角形になります。

public:
   void SetClipRectangle( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      Rectangle clipRect = Rectangle(0,0,100,100);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipRectangle(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 100, 100);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipRectangle(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New Rectangle(0, 0, 100, 100)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用対象

SetClip(Graphics)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、指定した GraphicsClip プロパティに設定します。

public:
 void SetClip(System::Drawing::Graphics ^ g);
public void SetClip (System.Drawing.Graphics g);
member this.SetClip : System.Drawing.Graphics -> unit
Public Sub SetClip (g As Graphics)

パラメーター

g
Graphics

新しいクリップ領域の取得元となる Graphics します。

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

  • 例の thisFormForm から一時的な Graphics を作成します。

  • 一時的な Graphics のクリッピング領域を小さな四角形に設定します。

  • フォームのグラフィック オブジェクトのクリッピング領域を、一時的な Graphicsの領域に更新します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、小さく塗りつぶされた黒い正方形になります。

public:
   void SetClipGraphics( PaintEventArgs^ e )
   {
      // Create temporary graphics object and set its clipping region.
      Graphics^ newGraphics = this->CreateGraphics();
      newGraphics->SetClip( Rectangle(0,0,100,100) );

      // Update clipping region of graphics to clipping region of new
      // graphics.
      e->Graphics->SetClip( newGraphics );

      // Fill rectangle to demonstrate clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );

      // Release new graphics.
      delete newGraphics;
   }
private void SetClipGraphics(PaintEventArgs e)
{

    // Create temporary graphics object and set its clipping region.
    Graphics newGraphics = this.CreateGraphics();
    newGraphics.SetClip(new Rectangle(0, 0, 100, 100));

    // Update clipping region of graphics to clipping region of new

    // graphics.
    e.Graphics.SetClip(newGraphics);

    // Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);

    // Release new graphics.
    newGraphics.Dispose();
}
Private Sub SetClipGraphics(ByVal e As PaintEventArgs)

    ' Create temporary graphics object and set its clipping region.
    Dim newGraphics As Graphics = Me.CreateGraphics()
    newGraphics.SetClip(New Rectangle(0, 0, 100, 100))

    ' Update clipping region of graphics to clipping region of new

    ' graphics.
    e.Graphics.SetClip(newGraphics)

    ' Fill rectangle to demonstrate clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)

    ' Release new graphics.
    newGraphics.Dispose()
End Sub

適用対象

SetClip(GraphicsPath)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

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

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

パラメーター

path
GraphicsPath

新しいクリップ領域を表す GraphicsPath

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

  • グラフィックス パスを作成し、パスに省略記号を追加します。

  • クリッピング領域を楕円パスに設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、塗りつぶされた黒い楕円になります。

public:
   void SetClipPath( PaintEventArgs^ e )
   {
      // Create graphics path.
      GraphicsPath^ clipPath = gcnew 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( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private 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);
}
Private Sub SetClipPath(ByVal 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

注釈

path パラメーターで表されるグラフィックス パスが閉じられない場合は、パスを閉じる最後のポイントから最初のポイントにセグメントが追加されます。

適用対象

SetClip(GraphicsPath, CombineMode)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics のクリッピング領域を、現在のクリップ領域と指定した GraphicsPathを組み合わせた指定した操作の結果に設定します。

public:
 void SetClip(System::Drawing::Drawing2D::GraphicsPath ^ path, System::Drawing::Drawing2D::CombineMode combineMode);
public void SetClip (System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Drawing2D.CombineMode combineMode);
member this.SetClip : System.Drawing.Drawing2D.GraphicsPath * System.Drawing.Drawing2D.CombineMode -> unit
Public Sub SetClip (path As GraphicsPath, combineMode As CombineMode)

パラメーター

path
GraphicsPath

結合する GraphicsPath

combineMode
CombineMode

使用する結合操作を指定する CombineMode 列挙体のメンバー。

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

  • グラフィックス パスを作成し、パスに省略記号を追加します。

  • クリッピング領域を、Replace メンバーを持つ楕円パスに設定します。

  • 大きな四角形に黒いソリッド ブラシを塗りつぶします。

結果は、塗りつぶされた黒い楕円になります。

public:
   void SetClipPathCombine( PaintEventArgs^ e )
   {
      // Create graphics path.
      GraphicsPath^ clipPath = gcnew GraphicsPath;
      clipPath->AddEllipse( 0, 0, 200, 100 );

      // Set clipping region to path.
      e->Graphics->SetClip( clipPath, CombineMode::Replace );

      // Fill rectangle to demonstrate clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void SetClipPathCombine(PaintEventArgs e)
{

    // Create graphics path.
    GraphicsPath clipPath = new GraphicsPath();
    clipPath.AddEllipse(0, 0, 200, 100);

    // Set clipping region to path.
    e.Graphics.SetClip(clipPath, CombineMode.Replace);

    // Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub SetClipPathCombine(ByVal 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, CombineMode.Replace)

    ' Fill rectangle to demonstrate clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

注釈

path パラメーターで表されるグラフィックス パスが閉じられない場合は、パスを閉じる最後のポイントから最初のポイントにセグメントが追加されます。

適用対象