RectangleF.Intersect Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Determina a RectangleF estrutura que representa a interseção de dois retângulos.
Sobrecargas
| Name | Description |
|---|---|
| Intersect(RectangleF, RectangleF) |
Devolve uma RectangleF estrutura que representa a interseção de dois retângulos. Se não houver interseção, e o vazio RectangleF for devolvido. |
| Intersect(RectangleF) |
Substitui esta RectangleF estrutura pela interseção entre si e a estrutura especificada RectangleF . |
Intersect(RectangleF, RectangleF)
Devolve uma RectangleF estrutura que representa a interseção de dois retângulos. Se não houver interseção, e o vazio RectangleF for devolvido.
public:
static System::Drawing::RectangleF Intersect(System::Drawing::RectangleF a, System::Drawing::RectangleF b);
public static System.Drawing.RectangleF Intersect(System.Drawing.RectangleF a, System.Drawing.RectangleF b);
static member Intersect : System.Drawing.RectangleF * System.Drawing.RectangleF -> System.Drawing.RectangleF
Public Shared Function Intersect (a As RectangleF, b As RectangleF) As RectangleF
Parâmetros
Um retângulo para se cruzar.
Um retângulo para se cruzar.
Devoluções
Uma terceira RectangleF estrutura, cujo tamanho representa a área sobreposta dos dois retângulos especificados.
Exemplos
Este exemplo foi concebido para uso com Windows Forms e requer PaintEventArgse, um objeto de evento OnPaint. O código cria dois RectangleF objetos e desenha-os para o ecrã em preto e vermelho. Repare que têm de ser convertidos em Rectangle objetos para fins de desenho. Depois, o código cria um terceiro RectangleF usando o Intersect método, converte-o para um Rectangle, e desenha-o para o ecrã em azul. Note que o terceiro retângulo (azul) é a área de sobreposição dos outros dois retângulos:
public:
void RectangleFIntersectExample( PaintEventArgs^ e )
{
// Create two rectangles.
RectangleF firstRectangleF = RectangleF(0,0,75,50);
RectangleF secondRectangleF = RectangleF(50,20,50,50);
// Convert the RectangleF structures to Rectangle structures and draw them to the
// screen.
Rectangle firstRect = Rectangle::Truncate( firstRectangleF );
Rectangle secondRect = Rectangle::Truncate( secondRectangleF );
e->Graphics->DrawRectangle( Pens::Black, firstRect );
e->Graphics->DrawRectangle( Pens::Red, secondRect );
// Get the intersection.
RectangleF intersectRectangleF = RectangleF::Intersect( firstRectangleF, secondRectangleF );
// Draw the intersectRectangleF to the screen.
Rectangle intersectRect = Rectangle::Truncate( intersectRectangleF );
e->Graphics->DrawRectangle( Pens::Blue, intersectRect );
}
public void RectangleFIntersectExample(PaintEventArgs e)
{
// Create two rectangles.
RectangleF firstRectangleF = new RectangleF(0, 0, 75, 50);
RectangleF secondRectangleF = new RectangleF(50, 20, 50, 50);
// Convert the RectangleF structures to Rectangle structures and draw them to the
// screen.
Rectangle firstRect = Rectangle.Truncate(firstRectangleF);
Rectangle secondRect = Rectangle.Truncate(secondRectangleF);
e.Graphics.DrawRectangle(Pens.Black, firstRect);
e.Graphics.DrawRectangle(Pens.Red, secondRect);
// Get the intersection.
RectangleF intersectRectangleF =
RectangleF.Intersect(firstRectangleF,
secondRectangleF);
// Draw the intersectRectangleF to the screen.
Rectangle intersectRect =
Rectangle.Truncate(intersectRectangleF);
e.Graphics.DrawRectangle(Pens.Blue, intersectRect);
}
Public Sub RectangleFIntersectExample(ByVal e As PaintEventArgs)
' Create two rectangles.
Dim firstRectangleF As New RectangleF(0, 0, 75, 50)
Dim secondRectangleF As New RectangleF(50, 20, 50, 50)
' Convert the RectangleF structures to Rectangle structures and
' draw them to the screen.
Dim firstRect As Rectangle = Rectangle.Truncate(firstRectangleF)
Dim secondRect As Rectangle = Rectangle.Truncate(secondRectangleF)
e.Graphics.DrawRectangle(Pens.Black, firstRect)
e.Graphics.DrawRectangle(Pens.Red, secondRect)
' Get the intersection.
Dim intersectRectangleF As RectangleF = _
RectangleF.Intersect(firstRectangleF, secondRectangleF)
' Draw the intersectRectangleF to the screen.
Dim intersectRect As Rectangle = _
Rectangle.Truncate(intersectRectangleF)
e.Graphics.DrawRectangle(Pens.Blue, intersectRect)
End Sub
Aplica-se a
Intersect(RectangleF)
Substitui esta RectangleF estrutura pela interseção entre si e a estrutura especificada RectangleF .
public:
void Intersect(System::Drawing::RectangleF rect);
public void Intersect(System.Drawing.RectangleF rect);
member this.Intersect : System.Drawing.RectangleF -> unit
Public Sub Intersect (rect As RectangleF)
Parâmetros
- rect
- RectangleF
O retângulo para se cruzar.