Επεξεργασία

Κοινή χρήση μέσω


GraphicsPath.Flatten Method

Definition

Converts each curve in this path into a sequence of connected line segments.

Overloads

Flatten()

Converts each curve in this path into a sequence of connected line segments.

Flatten(Matrix)

Applies the specified transform and then converts each curve in this GraphicsPath into a sequence of connected line segments.

Flatten(Matrix, Single)

Converts each curve in this GraphicsPath into a sequence of connected line segments.

Flatten()

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

Converts each curve in this path into a sequence of connected line segments.

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

Examples

For an example, see Flatten(Matrix, Single).

Applies to

Flatten(Matrix)

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

Applies the specified transform and then converts each curve in this GraphicsPath into a sequence of connected line segments.

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)

Parameters

matrix
Matrix

A Matrix by which to transform this GraphicsPath before flattening.

Examples

For an example, see Flatten(Matrix, Single).

Applies to

Flatten(Matrix, Single)

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

Converts each curve in this GraphicsPath into a sequence of connected line segments.

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)

Parameters

matrix
Matrix

A Matrix by which to transform this GraphicsPath before flattening.

flatness
Single

Specifies the maximum permitted error between the curve and its flattened approximation. A value of 0.25 is the default. Reducing the flatness value will increase the number of line segments in the approximation.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a graphics path and a translation matrix.

  • Adds a curve to the path using four points.

  • Draws the path (curve) to the screen, using a black pen.

  • Shifts the curve down 10 pixels and flattens it.

  • Draws the curve to the screen using, a red pen.

Notice that the red curve has flattened lines connecting the points.

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

Applies to