Rectangle Construtores
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.
Inicializa uma nova instância da Rectangle classe com a localização e tamanho especificados.
Sobrecargas
| Name | Description |
|---|---|
| Rectangle(Point, Size) |
Inicializa uma nova instância da Rectangle classe com a localização e tamanho especificados. |
| Rectangle(Int32, Int32, Int32, Int32) |
Inicializa uma nova instância da Rectangle classe com a localização e tamanho especificados. |
Rectangle(Point, Size)
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
Inicializa uma nova instância da Rectangle classe com a localização e tamanho especificados.
public:
Rectangle(System::Drawing::Point location, System::Drawing::Size size);
public Rectangle(System.Drawing.Point location, System.Drawing.Size size);
new System.Drawing.Rectangle : System.Drawing.Point * System.Drawing.Size -> System.Drawing.Rectangle
Public Sub New (location As Point, size As Size)
Parâmetros
Aplica-se a
Rectangle(Int32, Int32, Int32, Int32)
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
- Origem:
- Rectangle.cs
Inicializa uma nova instância da Rectangle classe com a localização e tamanho especificados.
public:
Rectangle(int x, int y, int width, int height);
public Rectangle(int x, int y, int width, int height);
new System.Drawing.Rectangle : int * int * int * int -> System.Drawing.Rectangle
Public Sub New (x As Integer, y As Integer, width As Integer, height As Integer)
Parâmetros
- x
- Int32
A coordenada x do canto superior esquerdo do retângulo.
- y
- Int32
A coordenada y do canto superior esquerdo do retângulo.
- width
- Int32
A largura do retângulo.
- height
- Int32
A altura do retângulo.
Exemplos
O exemplo de código seguinte demonstra os Rectangle, Intersect, IsEmpty, e IntersectsWith os membros. Este exemplo deve ser usado com um Windows Form. Cole este código num formulário e chame este método ao tratar o evento do Paint formulário, passando e como PaintEventArgs.
private:
void InstanceRectangleIntersection( PaintEventArgs^ e )
{
Rectangle rectangle1 = Rectangle(50,50,200,100);
Rectangle rectangle2 = Rectangle(70,20,100,200);
e->Graphics->DrawRectangle( Pens::Black, rectangle1 );
e->Graphics->DrawRectangle( Pens::Red, rectangle2 );
if ( rectangle1.IntersectsWith( rectangle2 ) )
{
rectangle1.Intersect( rectangle2 );
if ( !rectangle1.IsEmpty )
{
e->Graphics->FillRectangle( Brushes::Green, rectangle1 );
}
}
}
private void InstanceRectangleIntersection(PaintEventArgs e)
{
Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);
e.Graphics.DrawRectangle(Pens.Black, rectangle1);
e.Graphics.DrawRectangle(Pens.Red, rectangle2);
if (rectangle1.IntersectsWith(rectangle2))
{
rectangle1.Intersect(rectangle2);
if (!rectangle1.IsEmpty)
{
e.Graphics.FillRectangle(Brushes.Green, rectangle1);
}
}
}
Private Sub InstanceRectangleIntersection( _
ByVal e As PaintEventArgs)
Dim rectangle1 As New Rectangle(50, 50, 200, 100)
Dim rectangle2 As New Rectangle(70, 20, 100, 200)
e.Graphics.DrawRectangle(Pens.Black, rectangle1)
e.Graphics.DrawRectangle(Pens.Red, rectangle2)
If (rectangle1.IntersectsWith(rectangle2)) Then
rectangle1.Intersect(rectangle2)
If Not (rectangle1.IsEmpty) Then
e.Graphics.FillRectangle(Brushes.Green, rectangle1)
End If
End If
End Sub