Rectangle 생성자

정의

지정된 위치 및 크기를 사용하여 클래스의 Rectangle 새 인스턴스를 초기화합니다.

오버로드

Name Description
Rectangle(Point, Size)

지정된 위치 및 크기를 사용하여 클래스의 Rectangle 새 인스턴스를 초기화합니다.

Rectangle(Int32, Int32, Int32, Int32)

지정된 위치 및 크기를 사용하여 클래스의 Rectangle 새 인스턴스를 초기화합니다.

Rectangle(Point, Size)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

지정된 위치 및 크기를 사용하여 클래스의 Rectangle 새 인스턴스를 초기화합니다.

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)

매개 변수

location
Point

사각형 영역의 왼쪽 위 모퉁이를 나타내는 A Point 입니다.

size
Size

사각형 영역의 너비와 높이를 나타내는 A Size 입니다.

적용 대상

Rectangle(Int32, Int32, Int32, Int32)

Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs
Source:
Rectangle.cs

지정된 위치 및 크기를 사용하여 클래스의 Rectangle 새 인스턴스를 초기화합니다.

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)

매개 변수

x
Int32

사각형의 왼쪽 위 모퉁이에 대한 x 좌표입니다.

y
Int32

사각형의 왼쪽 위 모퉁이에 대한 y 좌표입니다.

width
Int32

사각형의 너비입니다.

height
Int32

사각형의 높이입니다.

예제

다음 코드 예제에서는 , RectangleIntersectIsEmpty 멤버를 IntersectsWith보여 줍니다. 이 예제는 Windows Form과 함께 사용해야 합니다. 양식에 이 코드를 붙여넣고 양식의 Paint 이벤트를 처리할 때 이 메서드를 호출하여 다음으로 e전달 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

적용 대상