語言

GraphicsPath.Flatten 方法

定義

將此路徑中的每條曲線轉換為一連串連接的線段。

多載

名稱 Description
Flatten()

將此路徑中的每條曲線轉換為一連串連接的線段。

Flatten(Matrix)

套用指定的轉換,然後將每條曲線 GraphicsPath 轉換成一連串的線段。

Flatten(Matrix, Single)

將每 GraphicsPath 條曲線轉換成一連串連接的線段。

Flatten()

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

A Matrix ,在壓平前先轉換此參數 GraphicsPath 。

範例

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

適用於

Flatten(Matrix, Single)

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

A Matrix ,在壓平前先轉換此參數 GraphicsPath 。

flatness
Single

指定曲線與其扁平近似之間的最大允許誤差。 預設值為 0.25。 降低平整度值會增加近似中的線段數量。

範例

以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 OnPaint 事件物件。 此程式碼會執行下列動作:

  • 建立圖形路徑和翻譯矩陣。

  • 用四個點在路徑上加入一條曲線。

  • 用黑色筆畫出路徑(曲線)到螢幕。

  • 將曲線向下移動 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

適用於