GraphicsPath 메서드에 FillPath 개체를 전달하여 경로를 채울 수 있습니다. FillPath 메서드는 현재 경로에 대해 설정된 채우기 모드(대체 또는 권선)에 따라 경로를 채웁니다. 경로에 열려 있는 도형이 있으면, 그 도형들이 닫혀 있는 것처럼 경로가 채워집니다. GDI+는 끝점에서 시작점으로 직선을 그려 그림을 닫습니다.
예시
다음 예제에서는 하나의 열린 그림(호)과 닫힌 그림(타원)이 있는 경로를 만듭니다. FillPath 메서드는 기본 채우기 모드(예: Alternate)에 따라 경로를 채웁니다.
다음 그림에서는 예제 코드의 출력을 보여 줍니다. 열린 그림이 끝점에서 시작점까지 직선으로 닫힌 것처럼 경로가 채워집니다(Alternate에 따라).
GraphicsPath path = new GraphicsPath();
// Add an open figure.
path.AddArc(0, 0, 150, 120, 30, 120);
// Add an intrinsically closed figure.
path.AddEllipse(50, 50, 50, 100);
Pen pen = new Pen(Color.FromArgb(128, 0, 0, 255), 5);
SolidBrush brush = new SolidBrush(Color.Red);
// The fill mode is FillMode.Alternate by default.
e.Graphics.FillPath(brush, path);
e.Graphics.DrawPath(pen, path);
Dim path As New GraphicsPath()
' Add an open figure.
path.AddArc(0, 0, 150, 120, 30, 120)
' Add an intrinsically closed figure.
path.AddEllipse(50, 50, 50, 100)
Dim pen As New Pen(Color.FromArgb(128, 0, 0, 255), 5)
Dim brush As New SolidBrush(Color.Red)
' The fill mode is FillMode.Alternate by default.
e.Graphics.FillPath(brush, path)
e.Graphics.DrawPath(pen, path)
코드 컴파일
앞의 예는 Windows Forms에서 사용하도록 설계되었으며 PaintEventArgs 이벤트 처리기의 매개 변수인 ePaint가 필요합니다.
참고하십시오
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET Desktop feedback