Rectangle 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 위치와 크기를 사용하여 Rectangle 클래스의 새 인스턴스를 초기화합니다.
오버로드
Rectangle(Point, Size) |
지정된 위치와 크기를 사용하여 Rectangle 클래스의 새 인스턴스를 초기화합니다. |
Rectangle(Int32, Int32, Int32, Int32) |
지정된 위치와 크기를 사용하여 Rectangle 클래스의 새 인스턴스를 초기화합니다. |
Rectangle(Point, Size)
- 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)
매개 변수
적용 대상
Rectangle(Int32, Int32, Int32, Int32)
- 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
사각형의 높이입니다.
예제
다음 코드 예제는 Rectangle, Intersect를 IsEmpty, 및 IntersectsWith 멤버입니다. 이 예제는 Windows Form과 함께 사용해야 합니다. 양식에 이 코드를 붙여넣고 양식의 Paint 이벤트를 처리할 때 이 메서드를 호출하여 로 PaintEventArgs전달 e
합니다.
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
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기