次の方法で共有


Graphics.TranslateTransform メソッド

定義

指定した平行移動をこの Graphicsの変換行列に先行して、座標系の原点を変更します。

オーバーロード

TranslateTransform(Single, Single, MatrixOrder)

この Graphics の変換行列に指定した平行移動を指定した順序で適用して、座標系の原点を変更します。

TranslateTransform(Single, Single)

指定した平行移動をこの Graphicsの変換行列に先行して、座標系の原点を変更します。

TranslateTransform(Single, Single, MatrixOrder)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

この Graphics の変換行列に指定した平行移動を指定した順序で適用して、座標系の原点を変更します。

public:
 void TranslateTransform(float dx, float dy, System::Drawing::Drawing2D::MatrixOrder order);
public void TranslateTransform (float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order);
member this.TranslateTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub TranslateTransform (dx As Single, dy As Single, order As MatrixOrder)

パラメーター

dx
Single

平行移動の x 座標。

dy
Single

平行移動の y 座標。

order
MatrixOrder

変換の前に変換を追加するか、変換マトリックスに追加するかを指定する MatrixOrder 列挙体のメンバー。

次のコード例は Windows フォームで使用できるように設計されており、Paint イベント ハンドラーのパラメーターである PaintEventArgseが必要です。 このコードは、次のアクションを実行します。

  • Windows フォームのワールド変換マトリックスを 30.0F 度回転します。

  • TranslateTransformを呼び出し、ワールド変換行列に平行移動を追加して、グラフィックス オブジェクトの原点を移動します。

  • 回転した翻訳された楕円を青いペンで描画します。

public:
   void TranslateTransformAngleMatrixOrder( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to translate, appending to world transform.
      e->Graphics->TranslateTransform( 100.0F, 0.0F, MatrixOrder::Append );

      // Draw rotated, translated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void TranslateTransformAngleMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to translate, appending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append);

    // Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub TranslateTransformAngleMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to translate, appending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append)

    ' Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

注釈

変換演算は、変換行列に、変換部分が dx および dy パラメーターである行列を乗算して構成されます。 このメソッドは、order パラメーターに従って、変換行列によって Graphics の変換行列の前に追加します。

こちらもご覧ください

適用対象

TranslateTransform(Single, Single)

ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs
ソース:
Graphics.cs

指定した平行移動をこの Graphicsの変換行列に先行して、座標系の原点を変更します。

public:
 void TranslateTransform(float dx, float dy);
public void TranslateTransform (float dx, float dy);
member this.TranslateTransform : single * single -> unit
Public Sub TranslateTransform (dx As Single, dy As Single)

パラメーター

dx
Single

平行移動の x 座標。

dy
Single

平行移動の y 座標。

次のコード例は Windows フォームで使用できるように設計されており、Paint イベント ハンドラーのパラメーターである PaintEventArgseが必要です。 このコードは、次のアクションを実行します。

  • Windows フォームのワールド変換マトリックスを 30.0F 度回転します。

  • 変換行列の前に TranslateTransformを呼び出して、グラフィックス オブジェクトの原点を移動します。

  • 青いペンを使用して、回転した翻訳された楕円を描画します。

public:
   void TranslateTransformAngle( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to translate, prepending to world transform.
      e->Graphics->TranslateTransform( 100.0F, 0.0F );

      // Draw translated, rotated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void TranslateTransformAngle(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to translate, prepending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub TranslateTransformAngle(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to translate, prepending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F)

    ' Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

次の図は、前のコード例の実行の出力を示しています。

翻訳および変換された楕円

注釈

原点は通常、描画サーフェイスの左上隅です。 変換演算は、変換行列に、変換部分が dx および dy パラメーターである行列を乗算して構成されます。 このメソッドは、変換行列を変換行列の前に置いて翻訳を適用します。

こちらもご覧ください

適用対象