GraphicsPath.Transform(Matrix) メソッド

定義

この 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

適用する変換を表す Matrix

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • パスを作成し、パスに省略記号を追加します。

  • 画面へのパスを描画します。

  • パスを x 軸方向に 100 単位翻訳する変換行列を作成します。

  • 変換されたパスを画面に描画します。

元の楕円が黒で描画され、変換された楕円が赤で描画されていることに注意してください。

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うことができます。

適用対象