GraphicsPath.StartFigure 方法

定义

不闭合当前图形即开始一个新图形。 后面添加到该路径的所有点都被添加到此新图形中。

public:
 void StartFigure();
public void StartFigure ();
member this.StartFigure : unit -> unit
Public Sub StartFigure ()

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse事件OnPaint对象。 此代码执行以下操作:

  • 创建路径。

  • 添加两组图形。 第一组图将四个基元合并为两个图形。 第二组图将相同的四个基元 (组合在一起,只是它们在 y 轴) 偏移成三个图形。

  • 将所有图形绘制到屏幕。

请注意这两组图形的外观差异。

public:
   void StartFigureExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object.
      GraphicsPath^ myPath = gcnew GraphicsPath;

      // First set of figures.
      myPath->StartFigure();
      myPath->AddArc( 10, 10, 50, 50, 0, 270 );
      myPath->AddLine( Point(50,0), Point(100,50) );
      myPath->AddArc( 50, 100, 75, 75, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddArc( 100, 10, 50, 50, 0, 270 );

      // Second set of figures.
      myPath->StartFigure();
      myPath->AddArc( 10, 200, 50, 50, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddLine( Point(60,200), Point(110,250) );
      myPath->AddArc( 50, 300, 75, 75, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddArc( 100, 200, 50, 50, 0, 270 );

      // Draw the path to the screen.
      e->Graphics->DrawPath( gcnew Pen( Color::Black ), myPath );
   }
   // End StartFigureExample
public void StartFigureExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object.
    GraphicsPath myPath = new GraphicsPath();
             
    // First set of figures.
    myPath.StartFigure();
    myPath.AddArc(10, 10, 50, 50, 0, 270);
    myPath.AddLine(new Point(50, 0), new Point(100, 50));
    myPath.AddArc(50, 100, 75, 75, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddArc(100, 10, 50, 50, 0, 270);
             
    // Second set of figures.
    myPath.StartFigure();
    myPath.AddArc(10, 200, 50, 50, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddLine(new Point(60, 200), new Point(110, 250));
    myPath.AddArc(50, 300, 75, 75, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddArc(100, 200, 50, 50, 0, 270);
             
    // Draw the path to the screen.
    e.Graphics.DrawPath(new Pen(Color.Black), myPath);
} 
// End StartFigureExample
Public Sub StartFigureExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object.
    Dim myPath As New GraphicsPath

    ' First set of figures.
    myPath.StartFigure()
    myPath.AddArc(10, 10, 50, 50, 0, 270)
    myPath.AddLine(New Point(50, 0), New Point(100, 50))
    myPath.AddArc(50, 100, 75, 75, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddArc(100, 10, 50, 50, 0, 270)

    ' Second set of figures.
    myPath.StartFigure()
    myPath.AddArc(10, 200, 50, 50, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddLine(New Point(60, 200), New Point(110, 250))
    myPath.AddArc(50, 300, 75, 75, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddArc(100, 200, 50, 50, 0, 270)

    ' Draw the path to the screen.
    e.Graphics.DrawPath(New Pen(Color.Black), myPath)
End Sub

注解

如果需要,用户必须保留原始点。 原始点在内部转换为三次方贝塞尔控制点,因此没有返回原始点的机制。

此方法在路径中启动一个新的子路径。 子路径允许将路径分为多个部分, GraphicsPathIterator 并使用 类循环访问子路径。

适用于