共用方式為


GraphicsPath.Flatten 方法

定義

將此路徑中的每個曲線轉換成連接線段序列。

多載

Flatten()

將此路徑中的每個曲線轉換成連接線段序列。

Flatten(Matrix)

套用指定的轉換,然後將這個 GraphicsPath 中的每個曲線轉換成連接線段序列。

Flatten(Matrix, Single)

將這個 GraphicsPath 中的每個曲線轉換成連接線段序列。

Flatten()

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs

將此路徑中的每個曲線轉換成連接線段序列。

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

範例

如需範例,請參閱 Flatten(Matrix, Single)

適用於

Flatten(Matrix)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
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 Forms 搭配使用,而且需要 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

適用於