GraphicsPath.Transform(Matrix) メソッド

定義

この GraphicsPath に変換行列を適用します。Applies a transform matrix to this GraphicsPath.

public:
 void Transform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Transform (System.Drawing.Drawing2D.Matrix matrix);
member this.Transform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Transform (matrix As Matrix)

パラメーター

matrix
Matrix

適用する変換を表す MatrixA Matrix that represents the transformation to apply.

次のコード例は、Windows フォームで使用するように設計されており、イベントオブジェクトを必要とし PaintEventArgs e OnPaint ます。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. コードは、次のアクションを実行します。The code performs the following actions:

  • パスを作成し、そのパスに楕円を追加します。Creates a path and adds an ellipse to the path.

  • 画面へのパスを描画します。Draws path to the screen.

  • X 軸方向のパス100単位を平行移動する変換行列を作成します。Creates a transform matrix to translate the path 100 units in the x-axis direction.

  • 変換されたパスを画面に描画します。Draws the transformed path to the screen.

元の楕円が黒で描画され、変換された楕円が赤で描画されることに注意してください。Notice that the original ellipse is drawn in black and the transformed ellipse is drawn in red.

private:
   void TransformExample( PaintEventArgs^ e )
   {
      // Create a path and add and ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddEllipse( 0, 0, 100, 200 );

      // Draw the starting position to screen.
      e->Graphics->DrawPath( Pens::Black, myPath );

      // Move the ellipse 100 points to the right.
      Matrix^ translateMatrix = gcnew Matrix;
      translateMatrix->Translate( 100, 0 );
      myPath->Transform(translateMatrix);

      // Draw the transformed ellipse to the screen.
      e->Graphics->DrawPath( gcnew Pen( Color::Red,2.0f ), myPath );
   }
private void TransformExample(PaintEventArgs e)
{
             
    // Create a path and add and ellipse.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddEllipse(0, 0, 100, 200);
             
    // Draw the starting position to screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
             
    // Move the ellipse 100 points to the right.
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(100, 0);
    myPath.Transform(translateMatrix);
             
    // Draw the transformed ellipse to the screen.
    e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)

    ' Create a path and add and ellipse.
    Dim myPath As New GraphicsPath
    myPath.AddEllipse(0, 0, 100, 200)

    ' Draw the starting position to screen.
    e.Graphics.DrawPath(Pens.Black, myPath)

    ' Move the ellipse 100 points to the right.
    Dim translateMatrix As New Matrix
    translateMatrix.Translate(100, 0)
    myPath.Transform(translateMatrix)

    ' Draw the transformed ellipse to the screen.
    e.Graphics.DrawPath(New Pen(Color.Red, 2), myPath)
End Sub

注釈

変換では、のスケール、平行移動、回転、または傾斜を行うことができ GraphicsPath ます。The transformation can scale, translate, rotate, or skew the GraphicsPath.

適用対象