Graphics.IntersectClip 方法

定義

將此 Graphics 區域的剪輯區域更新為當前剪輯區域與指定 Rectangle 結構的交集。

多載

名稱 Description
IntersectClip(Rectangle)

將此 Graphics 區域的剪輯區域更新為當前剪輯區域與指定 Rectangle 結構的交集。

IntersectClip(RectangleF)

將此 Graphics 區域的剪輯區域更新為當前剪輯區域與指定 RectangleF 結構的交集。

IntersectClip(Region)

將此 Graphics 片段區域更新為目前片段區域與指定的 Region

IntersectClip(Rectangle)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

將此 Graphics 區域的剪輯區域更新為當前剪輯區域與指定 Rectangle 結構的交集。

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

參數

rect
Rectangle

Rectangle 結構與當前剪輯區域相交。

範例

以下程式碼範例是為 Windows 表單設計,並需要 PaintEventArgse,這是事件處理器的 Paint 參數。 程式代碼會執行下列動作:

  • 建立左上角為 (0, 0) 的矩形,並將裁剪區域設定為此矩形。

  • 建立左上角為 (100, 100) 的第二個矩形,並將裁剪區域設定為此矩形的交集和目前的裁剪區域(第一個矩形)。

  • 以純藍色筆刷填滿包含上述兩個矩形的大型矩形。

  • 將裁剪區域重設為無限。

  • 在兩個裁剪區域周圍繪製矩形。 它會針對第一個裁剪矩形使用黑色畫筆,第二個裁剪區域的紅色畫筆。

結果是只有兩個矩形的交集填滿藍色。

public:
   void IntersectClipRectangle( PaintEventArgs^ e )
   {
      // Set clipping region.
      Rectangle clipRect = Rectangle(0,0,200,200);
      e->Graphics->SetClip( clipRect );

      // Update clipping region to intersection of
      // existing region with specified rectangle.
      Rectangle intersectRect = Rectangle(100,100,200,200);
      e->Graphics->IntersectClip( intersectRect );

      // Fill rectangle to demonstrate effective clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 500, 500 );

      // Reset clipping region to infinite.
      e->Graphics->ResetClip();

      // Draw clipRect and intersectRect to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Black ), clipRect );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red ), intersectRect );
   }
private 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);
}
Private Sub IntersectClipRectangle(ByVal 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

備註

此方法將當前剪輯區域與參數指定的rect矩形交點所代表的面積賦予Clip此性質Graphics

適用於

IntersectClip(RectangleF)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

將此 Graphics 區域的剪輯區域更新為當前剪輯區域與指定 RectangleF 結構的交集。

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

參數

rect
RectangleF

RectangleF 結構與當前剪輯區域相交。

範例

以下程式碼範例是為 Windows 表單設計,並需要 PaintEventArgse,這是事件處理器的 Paint 參數。 程式代碼會執行下列動作:

  • 建立左上角為 (0, 0) 的矩形,並將裁剪區域設定為此矩形。

  • 建立左上角為 (100, 100) 的第二個矩形,並將裁剪區域設定為此矩形的交集和目前的裁剪區域(第一個矩形)。

  • 以純藍色筆刷填滿包含上述兩個矩形的大型矩形。

  • 將裁剪區域重設為無限。

  • 在兩個裁剪區域周圍繪製矩形。 它會針對第一個裁剪矩形使用黑色畫筆,第二個裁剪區域的紅色畫筆。

結果是只有兩個矩形的交集填滿藍色。

public:
   void IntersectClipRectangleF1( PaintEventArgs^ e )
   {
      // Set clipping region.
      Rectangle clipRect = Rectangle(0,0,200,200);
      e->Graphics->SetClip( clipRect );

      // Update clipping region to intersection of
      // existing region with specified rectangle.
      RectangleF intersectRectF = RectangleF(100.0F,100.0F,200.0F,200.0F);
      e->Graphics->IntersectClip( intersectRectF );

      // Fill rectangle to demonstrate effective clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 500, 500 );

      // Reset clipping region to infinite.
      e->Graphics->ResetClip();

      // Draw clipRect and intersectRect to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Black ), clipRect );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red ), Rectangle::Round( intersectRectF ) );
   }
private void IntersectClipRectangleF1(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.
    RectangleF intersectRectF = new RectangleF(100.0F, 100.0F, 200.0F, 200.0F);
    e.Graphics.IntersectClip(intersectRectF);

    // 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), Rectangle.Round(intersectRectF));
}
Private Sub IntersectClipRectangleF1(ByVal 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 intersectRectF As New RectangleF(100.0F, 100.0F, 200.0F, 200.0F)
    e.Graphics.IntersectClip(intersectRectF)

    ' 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), _
    Rectangle.Round(intersectRectF))
End Sub

備註

此方法將當前剪輯區域與參數指定的rect矩形交點所代表的面積賦予Clip此性質Graphics

適用於

IntersectClip(Region)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

將此 Graphics 片段區域更新為目前片段區域與指定的 Region

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

參數

region
Region

Region 與現有區域交會。

範例

以下程式碼範例是為 Windows 表單設計,並需要 PaintEventArgse,這是事件處理器的 Paint 參數。 程式代碼會執行下列動作:

  • 建立左上角為 (0, 0) 的矩形。

  • 建立區域並將它設定為矩形,並將裁剪區域設定為這個區域。

  • 建立左上角為 (100, 100) 的第二個矩形。

  • 建立一個區域並將其設為第二個矩形,並將裁剪區域設為該區域與當前裁剪區域(第一個矩形)的交點,使用結合模式。Replace

  • 以純藍色筆刷填滿包含上述兩個區域的大型矩形。

  • 將裁剪區域重設為無限。

  • 在兩個裁剪區域周圍繪製矩形。 它會針對第一個裁剪區域使用黑色畫筆,第二個裁剪區域的紅色畫筆。

結果是只有兩個區域的交集會填滿藍色。

public:
   void IntersectClipRegion( PaintEventArgs^ e )
   {
      // Set clipping region.
      Rectangle clipRect = Rectangle(0,0,200,200);
      System::Drawing::Region^ clipRegion = gcnew System::Drawing::Region( clipRect );
      e->Graphics->SetClip( clipRegion, CombineMode::Replace );

      // Update clipping region to intersection of
      // existing region with specified rectangle.
      Rectangle intersectRect = Rectangle(100,100,200,200);
      System::Drawing::Region^ intersectRegion = gcnew System::Drawing::Region( intersectRect );
      e->Graphics->IntersectClip( intersectRegion );

      // Fill rectangle to demonstrate effective clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 500, 500 );

      // Reset clipping region to infinite.
      e->Graphics->ResetClip();

      // Draw clipRect and intersectRect to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Black ), clipRect );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red ), intersectRect );
   }
private 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);
}
Private Sub IntersectClipRegion(ByVal 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

備註

此方法將當前剪輯區域與參數指定region區域的交點所代表的區域賦予Clip此屬性Graphics

適用於