GraphicsPath.Warp メソッド (PointF , RectangleF, Matrix, WarpMode, Single)
GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。
Overloads Public Sub Warp( _
ByVal destPoints() As PointF, _ ByVal srcRect As RectangleF, _ ByVal matrix As Matrix, _ ByVal warpMode As WarpMode, _ ByVal flatness As Single _)
[C#]
public void Warp(PointF[] destPoints,RectangleFsrcRect,Matrixmatrix,WarpModewarpMode,floatflatness);
[C++]
public: void Warp(PointFdestPoints[],RectangleFsrcRect,Matrix* matrix,WarpModewarpMode,floatflatness);
[JScript]
public function Warp(
destPoints : PointF[],srcRect : RectangleF,matrix : Matrix,warpMode : WarpMode,flatness : float);
パラメータ
- destPoints
srcRect によって定義された四角形を変形した結果の平行四辺形を定義する PointF 構造体の配列。配列には、3 つまたは 4 つの要素を含めることができます。配列に 3 つの要素が含まれている場合、平行四辺形の右下の頂点は最初の 3 つの点から類推されます。 - srcRect
destPoints によって定義された平行四辺形に変形される四角形を表す RectangleF 構造体。 - matrix
パスに適用するジオメトリック変換を指定する Matrix オブジェクト。 - warpMode
この変形操作で遠近モードまたは双一次モードを使用するかどうかを指定する WarpMode 列挙体。 - flatness
結果として生成されたパスの平坦度を指定する 0 から 1 の値。詳細については、 Flatten メソッドのトピックを参照してください。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- パスを作成し、そのパスに四角形を追加します。
- その四角形を黒で画面に描画します。
- 遠近ワープでパスを変形します。
- 変形した四角形 (パス) を赤で画面に描画します。
Public Sub WarpExample(e As PaintEventArgs)
' Create a path and add a rectangle.
Dim myPath As New GraphicsPath()
Dim srcRect As 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.
Dim point1 As New PointF(200, 200)
Dim point2 As New PointF(400, 250)
Dim point3 As New PointF(220, 400)
Dim destPoints As PointF() = {point1, point2, point3}
' Create a translation matrix.
Dim translateMatrix As 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)
End Sub
[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);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間 | GraphicsPath.Warp オーバーロードの一覧