Graphics.IntersectClip 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
IntersectClip(Rectangle) | |
IntersectClip(RectangleF) |
将此 Graphics 的剪辑区域更新为当前剪辑区域的交集和指定的 RectangleF 结构。 |
IntersectClip(Region) |
IntersectClip(Rectangle)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
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)
参数
示例
下面的代码示例设计用于 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
注解
此方法分配给此 Graphics 由当前剪辑区域的交集和由 rect
参数指定的矩形所表示的区域 Clip 属性。
适用于
IntersectClip(RectangleF)
- Source:
- Graphics.cs
- Source:
- 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
注解
此方法分配给此 Graphics 由当前剪辑区域的交集和由 rect
参数指定的矩形所表示的区域 Clip 属性。
适用于
IntersectClip(Region)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
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)
参数
示例
下面的代码示例设计用于 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
注解
此方法分配给此 Graphics 当前剪辑区域的交集和由 region
参数指定的区域 Clip 属性。