次の方法で共有


GraphicsPath.Warp メソッド

GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。

オーバーロードの一覧

GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。

[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF)

[C#] public void Warp(PointF[], RectangleF);

[C++] public: void Warp(PointF[], RectangleF);

[JScript] public function Warp(PointF[], RectangleF);

GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。

[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix)

[C#] public void Warp(PointF[], RectangleF, Matrix);

[C++] public: void Warp(PointF[], RectangleF, Matrix*);

[JScript] public function Warp(PointF[], RectangleF, Matrix);

GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。

[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix, WarpMode)

[C#] public void Warp(PointF[], RectangleF, Matrix, WarpMode);

[C++] public: void Warp(PointF[], RectangleF, Matrix*, WarpMode);

[JScript] public function Warp(PointF[], RectangleF, Matrix, WarpMode);

GraphicsPath オブジェクトに、四角形と平行四辺形によって定義されたワープ変換を適用します。

[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix, WarpMode, Single)

[C#] public void Warp(PointF[], RectangleF, Matrix, WarpMode, float);

[C++] public: void Warp(PointF[], RectangleF, Matrix*, WarpMode, float);

[JScript] public function Warp(PointF[], RectangleF, Matrix, WarpMode, float);

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • パスを作成し、そのパスに四角形を追加します。
  • その四角形を黒で画面に描画します。
  • 遠近ワープでパスを変形します。
  • 変形した四角形 (パス) を赤で画面に描画します。

[Visual Basic, C#] メモ   ここでは、Warp のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
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# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間