指定した寸法でローカル ジオメトリック変換を平行移動します。このメソッドは変換の前に平行移動を行います。
オーバーロードの一覧
指定した寸法でローカル ジオメトリック変換を平行移動します。このメソッドは変換の前に平行移動を行います。
[Visual Basic] Overloads Public Sub TranslateTransform(Single, Single)
指定した順序で、指定した寸法だけローカル ジオメトリック変換を平行移動します。
[Visual Basic] Overloads Public Sub TranslateTransform(Single, Single, MatrixOrder)
[C#] public void TranslateTransform(float, float, MatrixOrder);
[C++] public: void TranslateTransform(float, float, MatrixOrder);
[JScript] public function TranslateTransform(float, float, MatrixOrder);
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- 新しい LinearGradientBrush オブジェクトを作成します。
- このブラシを使用して、左から右へ線形に色が変化するグラデーションを持つ四角形を画面に描画します。
- LinearGradientBrush オブジェクトを 90 度回転し、グラデーションをスケールします。
- 回転され、グラデーションがスケールされた四角形を画面に描画します。
- 上から下へ線形グラデーションされるよう四角形を平行移動します。
- 画面に平行移動された四角形を描画します。
[Visual Basic, C#] 3 つの四角形が表示され、1 番上の四角形は左から右へのグラデーション、中央の四角形は回転およびスケールされたグラデーション、1 番下の四角形は最終的に平行移動されたグラデーションになります。
[Visual Basic, C#] メモ ここでは、TranslateTransform のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
Public Sub TranslateTransformExample(e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
Color.Red, 0F, True)
' Draw a rectangle to the screen using the LinearGradientBrush.
e.Graphics.FillRectangle(myLGBrush, myRect)
' Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(90F)
' Scale the gradient for the height of the rectangle.
myLGBrush.ScaleTransform(0.5F, 1F)
' Draw to the screen, the rotated and scaled gradient.
e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100)
' Rejustify the brush to start at the top edge of the rectangle.
myLGBrush.TranslateTransform(- 20F, 0F)
' Draw a third rectangle to the screen using the translated brush.
e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100)
End Sub
[C#]
private void TranslateTransformExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new LinearGradientBrush(
myRect,
Color.Blue,
Color.Red,
0.0f,
true);
// Draw a rectangle to the screen using the LinearGradientBrush.
e.Graphics.FillRectangle(myLGBrush, myRect);
// Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(90.0f);
// Scale the gradient for the height of the rectangle.
myLGBrush.ScaleTransform(0.5f, 1.0f);
// Draw to the screen, the rotated and scaled gradient.
e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100);
// Rejustify the brush to start at the top edge of the
// rectangle.
myLGBrush.TranslateTransform(-20.0f, 0.0f);
// Draw a third rectangle to the screen using the translated
// brush.
e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
参照
LinearGradientBrush クラス | LinearGradientBrush メンバ | System.Drawing.Drawing2D 名前空間