GraphicsPath.Flatten 方法

定義

將這個路徑中的每條曲線轉型為連接的直線線段序列。

多載

Flatten()

將這個路徑中的每條曲線轉型為連接的直線線段序列。

Flatten(Matrix)

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

Flatten(Matrix, Single)

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

Flatten()

來源:
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 中的每條曲線轉換為連接的直線線段序列。

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

Matrix,用來在簡維前轉換這個 GraphicsPath

範例

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

適用於

Flatten(Matrix, Single)

來源:
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

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

適用於