Graphics.DrawLine 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
좌표 쌍으로 지정된 두 점을 연결하는 선을 그립니다.
오버로드
| DrawLine(Pen, Int32, Int32, Int32, Int32) |
좌표 쌍으로 지정된 두 점을 연결하는 선을 그립니다. |
| DrawLine(Pen, Single, Single, Single, Single) |
좌표 쌍으로 지정된 두 점을 연결하는 선을 그립니다. |
| DrawLine(Pen, Point, Point) |
두 Point 구조체를 연결하는 선을 그립니다. |
| DrawLine(Pen, PointF, PointF) |
두 PointF 구조체를 연결하는 선을 그립니다. |
DrawLine(Pen, Int32, Int32, Int32, Int32)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
좌표 쌍으로 지정된 두 점을 연결하는 선을 그립니다.
public:
void DrawLine(System::Drawing::Pen ^ pen, int x1, int y1, int x2, int y2);
public void DrawLine (System.Drawing.Pen pen, int x1, int y1, int x2, int y2);
member this.DrawLine : System.Drawing.Pen * int * int * int * int -> unit
Public Sub DrawLine (pen As Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)
매개 변수
- x1
- Int32
첫 번째 점의 x 좌표입니다.
- y1
- Int32
첫 번째 점의 y 좌표입니다.
- x2
- Int32
두 번째 점의 x 좌표입니다.
- y2
- Int32
두 번째 점의 y 좌표입니다.
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
선 끝점의 좌표를 만듭니다.
화면에 선을 그립니다.
public:
void DrawLineInt( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create coordinates of points that define line.
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 100;
// Draw line to screen.
e->Graphics->DrawLine( blackPen, x1, y1, x2, y2 );
}
public void DrawLineInt(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create coordinates of points that define line.
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 100;
// Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
Public Sub DrawLineInt(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create coordinates of points that define line.
Dim x1 As Integer = 100
Dim y1 As Integer = 100
Dim x2 As Integer = 500
Dim y2 As Integer = 100
' Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)
End Sub
설명
이 메서드는 x1, y1, x2및 y2 매개 변수로 지정된 두 점을 연결하는 선을 그립니다.
추가 정보
- 펜을 사용하여 선과 도형 그리기
적용 대상
DrawLine(Pen, Single, Single, Single, Single)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
좌표 쌍으로 지정된 두 점을 연결하는 선을 그립니다.
public:
void DrawLine(System::Drawing::Pen ^ pen, float x1, float y1, float x2, float y2);
public void DrawLine (System.Drawing.Pen pen, float x1, float y1, float x2, float y2);
member this.DrawLine : System.Drawing.Pen * single * single * single * single -> unit
Public Sub DrawLine (pen As Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)
매개 변수
- x1
- Single
첫 번째 점의 x 좌표입니다.
- y1
- Single
첫 번째 점의 y 좌표입니다.
- x2
- Single
두 번째 점의 x 좌표입니다.
- y2
- Single
두 번째 점의 y 좌표입니다.
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
선 끝점의 좌표를 만듭니다.
화면에 선을 그립니다.
public:
void DrawLineFloat( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create coordinates of points that define line.
float x1 = 100.0F;
float y1 = 100.0F;
float x2 = 500.0F;
float y2 = 100.0F;
// Draw line to screen.
e->Graphics->DrawLine( blackPen, x1, y1, x2, y2 );
}
public void DrawLineFloat(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create coordinates of points that define line.
float x1 = 100.0F;
float y1 = 100.0F;
float x2 = 500.0F;
float y2 = 100.0F;
// Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
Public Sub DrawLineFloat(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create coordinates of points that define line.
Dim x1 As Single = 100.0F
Dim y1 As Single = 100.0F
Dim x2 As Single = 500.0F
Dim y2 As Single = 100.0F
' Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)
End Sub
설명
이 메서드는 x1, y1, x2및 y2 매개 변수로 지정된 두 점을 연결하는 선을 그립니다.
추가 정보
- 펜을 사용하여 선과 도형 그리기
적용 대상
DrawLine(Pen, Point, Point)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
두 Point 구조체를 연결하는 선을 그립니다.
public:
void DrawLine(System::Drawing::Pen ^ pen, System::Drawing::Point pt1, System::Drawing::Point pt2);
public void DrawLine (System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2);
member this.DrawLine : System.Drawing.Pen * System.Drawing.Point * System.Drawing.Point -> unit
Public Sub DrawLine (pen As Pen, pt1 As Point, pt2 As Point)
매개 변수
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
줄의 엔드포인트에 대한 점을 만듭니다.
화면에 선을 그립니다.
public:
void DrawLinePoint( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create points that define line.
Point point1 = Point(100,100);
Point point2 = Point(500,100);
// Draw line to screen.
e->Graphics->DrawLine( blackPen, point1, point2 );
}
public void DrawLinePoint(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create points that define line.
Point point1 = new Point(100, 100);
Point point2 = new Point(500, 100);
// Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2);
}
Public Sub DrawLinePoint(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define line.
Dim point1 As New Point(100, 100)
Dim point2 As New Point(500, 100)
' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)
End Sub
추가 정보
- 펜을 사용하여 선과 도형 그리기
적용 대상
DrawLine(Pen, PointF, PointF)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
두 PointF 구조체를 연결하는 선을 그립니다.
public:
void DrawLine(System::Drawing::Pen ^ pen, System::Drawing::PointF pt1, System::Drawing::PointF pt2);
public void DrawLine (System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2);
member this.DrawLine : System.Drawing.Pen * System.Drawing.PointF * System.Drawing.PointF -> unit
Public Sub DrawLine (pen As Pen, pt1 As PointF, pt2 As PointF)
매개 변수
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
줄의 엔드포인트에 대한 점을 만듭니다.
화면에 선을 그립니다.
public:
void DrawLinePointF( PaintEventArgs^ e )
{
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create points that define line.
PointF point1 = PointF(100.0F,100.0F);
PointF point2 = PointF(500.0F,100.0F);
// Draw line to screen.
e->Graphics->DrawLine( blackPen, point1, point2 );
}
public void DrawLinePointF(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create points that define line.
PointF point1 = new PointF(100.0F, 100.0F);
PointF point2 = new PointF(500.0F, 100.0F);
// Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2);
}
Public Sub DrawLinePointF(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define line.
Dim point1 As New PointF(100.0F, 100.0F)
Dim point2 As New PointF(500.0F, 100.0F)
' Draw line to screen.
e.Graphics.DrawLine(blackPen, point1, point2)
End Sub
설명
이 메서드는 pt1 및 p2 매개 변수로 지정된 두 점을 연결하는 선을 그립니다.
추가 정보
- 펜을 사용하여 선과 도형 그리기