GraphicsPath.Flatten 方法

定义

将此路径中的每个曲线转换为连接的线段序列。

重载

Flatten()

将此路径中的每个曲线转换为连接的线段序列。

Flatten(Matrix)

应用指定的转换,然后将此 GraphicsPath 中的每个曲线转换为连接的线段序列。

Flatten(Matrix, Single)

将此 GraphicsPath 中的每个曲线转换为连接的线段序列。

Flatten()

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

将此路径中的每个曲线转换为连接的线段序列。

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

示例

有关示例,请参阅 Flatten(Matrix, Single)

适用于

Flatten(Matrix)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

应用指定的转换,然后将此 GraphicsPath 中的每个曲线转换为连接的线段序列。

public:
 void Flatten(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Flatten (System.Drawing.Drawing2D.Matrix? matrix);
public void Flatten (System.Drawing.Drawing2D.Matrix matrix);
member this.Flatten : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Flatten (matrix As Matrix)

参数

matrix
Matrix

在平展之前转换此 GraphicsPathMatrix

示例

有关示例,请参阅 Flatten(Matrix, Single)

适用于

Flatten(Matrix, Single)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

将此 GraphicsPath 中的每个曲线转换为连接的线段序列。

public:
 void Flatten(System::Drawing::Drawing2D::Matrix ^ matrix, float flatness);
public void Flatten (System.Drawing.Drawing2D.Matrix? matrix, float flatness);
public void Flatten (System.Drawing.Drawing2D.Matrix matrix, float flatness);
member this.Flatten : System.Drawing.Drawing2D.Matrix * single -> unit
Public Sub Flatten (matrix As Matrix, flatness As Single)

参数

matrix
Matrix

在平展之前转换此 GraphicsPathMatrix

flatness
Single

指定曲线与其平展近似值之间的允许的最大误差。 默认值为 0.25。 减少平整值会增加近似值中的线段数。

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建图形路径和翻译矩阵。

  • 使用四个点向路径添加曲线。

  • 使用黑色笔将路径(曲线)绘制到屏幕。

  • 将曲线向下移 10 像素并平展它。

  • 使用红色笔将曲线绘制到屏幕。

请注意,红色曲线已平展连接点的线条。

private:
   void FlattenExample( PaintEventArgs^ e )
   {
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Matrix^ translateMatrix = gcnew Matrix;
      translateMatrix->Translate( 0, 10 );
      Point point1 = Point(20,100);
      Point point2 = Point(70,10);
      Point point3 = Point(130,200);
      Point point4 = Point(180,100);
      array<Point>^ points = {point1,point2,point3,point4};
      myPath->AddCurve( points );
      e->Graphics->DrawPath( gcnew Pen( Color::Black,2.0f ), myPath );
      myPath->Flatten( translateMatrix, 10.0f );
      e->Graphics->DrawPath( gcnew Pen( Color::Red,1.0f ), myPath );
   }
private void FlattenExample(PaintEventArgs e)
{
    GraphicsPath myPath = new GraphicsPath();
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(0, 10);
    Point point1 = new Point(20, 100);
    Point point2 = new Point(70, 10);
    Point point3 = new Point(130, 200);
    Point point4 = new Point(180, 100);
    Point[] points = {point1, point2, point3, point4};
    myPath.AddCurve(points);
    e.Graphics.DrawPath(new Pen(Color.Black, 2), myPath);
    myPath.Flatten(translateMatrix, 10f);
    e.Graphics.DrawPath(new Pen(Color.Red, 1), myPath);
}
Public Sub FlattenExample(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    Dim translateMatrix As New Matrix
    translateMatrix.Translate(0, 10)
    Dim point1 As New Point(20, 100)
    Dim point2 As New Point(70, 10)
    Dim point3 As New Point(130, 200)
    Dim point4 As New Point(180, 100)
    Dim points As Point() = {point1, point2, point3, point4}
    myPath.AddCurve(points)
    e.Graphics.DrawPath(New Pen(Color.Black, 2), myPath)
    myPath.Flatten(translateMatrix, 10.0F)
    e.Graphics.DrawPath(New Pen(Color.Red, 1), myPath)
End Sub
'FlattenExample

适用于