GraphicsPath.Warp 方法

定義

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

多載

Warp(PointF[], RectangleF)

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

Warp(PointF[], RectangleF, Matrix)

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

Warp(PointF[], RectangleF, Matrix, WarpMode)

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

Warp(ReadOnlySpan<PointF>, RectangleF, Matrix, WarpMode, Single)

Warp(PointF[], RectangleF)

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

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect);

參數

destPoints
PointF[]

PointF 結構的陣列,定義 srcRect 所定義矩形的平行投影。 陣列可以包含三個或四個元素。 如果陣列包含三個元素,平行投影的右下角會由前三個點隱含。

srcRect
RectangleF

RectangleF,表示轉換成 destPoints所定義的平行投影的矩形。

範例

如需範例,請參閱 Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Warp(PointF[], RectangleF, Matrix)

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

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix);
C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix);

參數

destPoints
PointF[]

PointF 結構的陣列,定義 srcRect 所定義矩形的平行投影。 陣列可以包含三個或四個元素。 如果陣列包含三個元素,平行投影的右下角會由前三個點隱含。

srcRect
RectangleF

RectangleF,表示轉換成 destPoints所定義的平行投影的矩形。

matrix
Matrix

Matrix,指定要套用至路徑的幾何轉換。

範例

如需範例,請參閱 Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Warp(PointF[], RectangleF, Matrix, WarpMode)

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

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode);
C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode);

參數

destPoints
PointF[]

PointF 結構的陣列,定義 srcRect 所定義矩形的平行投影轉換。 陣列可以包含三個或四個元素。 如果陣列包含三個元素,平行投影的右下角會由前三個點隱含。

srcRect
RectangleF

RectangleF,表示轉換成 destPoints所定義的平行投影的矩形。

matrix
Matrix

Matrix,指定要套用至路徑的幾何轉換。

warpMode
WarpMode

WarpMode 列舉,指定此變形作業是否使用透視模式或雙線性模式。

範例

如需範例,請參閱 Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

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

將矩形和平行投影所定義的扭曲轉換套用至這個 GraphicsPath

C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);
C#
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);

參數

destPoints
PointF[]

PointF 結構的陣列,定義 srcRect 所定義矩形的平行投影。 陣列可以包含三個或四個元素。 如果陣列包含三個元素,平行投影的右下角會由前三個點隱含。

srcRect
RectangleF

RectangleF,表示轉換成 destPoints所定義的平行投影的矩形。

matrix
Matrix

Matrix,指定要套用至路徑的幾何轉換。

warpMode
WarpMode

WarpMode 列舉,指定此變形作業是否使用透視模式或雙線性模式。

flatness
Single

從 0 到 1 的值,指定結果路徑的平面程度。 如需詳細資訊,請參閱 Flatten() 方法。

範例

下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgseOnPaint 事件物件。 程式代碼會執行下列動作:

  • 建立路徑,並將矩形新增至路徑。

  • 以黑色繪製該矩形到螢幕。

  • 用透視扭曲來扭曲路徑。

  • 以紅色將扭曲的矩形(路徑)繪製到螢幕。

C#
private void WarpExample(PaintEventArgs e)
{
             
    // Create a path and add a rectangle.
    GraphicsPath myPath = new GraphicsPath();
    RectangleF srcRect = new RectangleF(0, 0, 100, 200);
    myPath.AddRectangle(srcRect);
             
    // Draw the source path (rectangle)to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
             
    // Create a destination for the warped rectangle.
    PointF point1 = new PointF(200, 200);
    PointF point2 = new PointF(400, 250);
    PointF point3 = new PointF(220, 400);
    PointF[] destPoints = {point1, point2, point3};
             
    // Create a translation matrix.
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(100, 0);
             
    // Warp the source path (rectangle).
    myPath.Warp(destPoints, srcRect, translateMatrix,
        WarpMode.Perspective, 0.5f);
             
    // Draw the warped path (rectangle) to the screen.
    e.Graphics.DrawPath(new Pen(Color.Red), myPath);
}

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Warp(ReadOnlySpan<PointF>, RectangleF, Matrix, WarpMode, Single)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
C#
public void Warp (ReadOnlySpan<System.Drawing.PointF> destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix = default, System.Drawing.Drawing2D.WarpMode warpMode = System.Drawing.Drawing2D.WarpMode.Perspective, float flatness = 0.25);

參數

destPoints
ReadOnlySpan<PointF>
srcRect
RectangleF
matrix
Matrix
warpMode
WarpMode
flatness
Single

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9