Share via


GDI+의 개곡선 및 폐곡선

다음 그림에서는 개곡선과 폐곡선, 두 가지 곡선을 보여줍니다.

열린 곡선 1개 및 닫힌 곡선 1개의 스크린샷.

곡선에 대한 관리형 인터페이스

폐곡선은 내부를 가지므로 브러시로 채워질 수 있습니다. GDI+의 Graphics 클래스는 닫힌 도형 및 폐곡선을 채우기 위해 FillRectangle, FillEllipse, FillPie, FillPolygon, FillClosedCurve, FillPathFillRegion 메서드를 제공합니다. 이러한 메서드 중 하나를 호출할 때마다 특정 브러시 유형 중 하나(SolidBrush, HatchBrush, TextureBrush, LinearGradientBrush 또는 PathGradientBrush)를 인수로 전달해야 합니다.

FillPie 메서드는 DrawArc 메서드의 도우미입니다. DrawArc 메서드가 타원의 윤곽선 일부를 그릴 때처럼, FillPie 메서드는 타원의 내부 일부를 채웁니다. 다음 예제에서는 호를 그리고 타원 내부의 해당 부분을 채웁니다.

myGraphics.FillPie(mySolidBrush, 0, 0, 140, 70, 0, 120);
myGraphics.DrawArc(myPen, 0, 0, 140, 70, 0, 120);
myGraphics.FillPie(mySolidBrush, 0, 0, 140, 70, 0, 120)
myGraphics.DrawArc(myPen, 0, 0, 140, 70, 0, 120)

다음 그림에서는 호와 채워진 원형을 보여줍니다.

호와 채워진 파이의 스크린샷.

FillClosedCurve 메서드는 DrawClosedCurve 메서드의 도우미입니다. 두 메서드 모두 끝점을 시작점에 연결하여 곡선을 자동으로 닫습니다. 다음 예제에서는 (0, 0), (60, 20) 및 (40, 50)을 통과하는 곡선을 그립니다. 그러면, (40, 50)을 시작점(0, 0)에 연결하여 곡선이 자동으로 닫히고 내부는 단색으로 채워집니다.

Point[] myPointArray =
{
    new Point(0, 0),
    new Point(60, 20),
    new Point(40, 50)
};
myGraphics.DrawClosedCurve(myPen, myPointArray);
myGraphics.FillClosedCurve(mySolidBrush, myPointArray);
Dim myPointArray As Point() = _
   {New Point(0, 0), New Point(60, 20), New Point(40, 50)}
myGraphics.DrawClosedCurve(myPen, myPointArray)
myGraphics.FillClosedCurve(mySolidBrush, myPointArray)

FillPath 메서드는 경로의 개별 부분 내부를 채웁니다. 경로의 일부가 폐곡선 또는 닫힌 도형을 형성하지 않으면 FillPath 메서드가 경로를 채우기 전에 경로의 해당 부분을 자동으로 닫습니다. 다음 예제에서는 호, 카디널 스플라인, 문자열 및 원형으로 구성된 경로를 그리고 채웁니다.

SolidBrush mySolidBrush = new SolidBrush(Color.Aqua);
GraphicsPath myGraphicsPath = new GraphicsPath();

Point[] myPointArray =
{
    new Point(15, 20),
    new Point(20, 40),
    new Point(50, 30)
};

FontFamily myFontFamily = new FontFamily("Times New Roman");
PointF myPointF = new PointF(50, 20);
StringFormat myStringFormat = new StringFormat();

myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180);
myGraphicsPath.AddCurve(myPointArray);
myGraphicsPath.AddString("a string in a path", myFontFamily,
   0, 24, myPointF, myStringFormat);
myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110);

myGraphics.FillPath(mySolidBrush, myGraphicsPath);
myGraphics.DrawPath(myPen, myGraphicsPath);
Dim mySolidBrush As New SolidBrush(Color.Aqua)
Dim myGraphicsPath As New GraphicsPath()

Dim myPointArray As Point() = { _
   New Point(15, 20), _
   New Point(20, 40), _
   New Point(50, 30)}

Dim myFontFamily As New FontFamily("Times New Roman")
Dim myPointF As New PointF(50, 20)
Dim myStringFormat As New StringFormat()

myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180)
myGraphicsPath.AddCurve(myPointArray)
myGraphicsPath.AddString("a string in a path", myFontFamily, _
   0, 24, myPointF, myStringFormat)
myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110)

myGraphics.FillPath(mySolidBrush, myGraphicsPath)
myGraphics.DrawPath(myPen, myGraphicsPath)

다음 그림에서는 단색 채우기가 있는 경로와 없는 경로를 보여줍니다. 문자열의 텍스트는 DrawPath 메서드에 의해 윤곽선이 그려져 있지만 채워지지는 않습니다. 문자열에 있는 문자의 내부를 칠하는 것은 FillPath 메서드입니다.

경로의 문자열

참고 항목