指定した順序で、指定した寸法だけローカル ジオメトリック変換を平行移動します。
Overloads Public Sub TranslateTransform( _
ByVal dx As Single, _ ByVal dy As Single, _ ByVal order As MatrixOrder _)
[C#]
public void TranslateTransform(floatdx,floatdy,MatrixOrderorder);
[C++]
public: void TranslateTransform(floatdx,floatdy,MatrixOrderorder);
[JScript]
public function TranslateTransform(
dx : float,dy : float,order : MatrixOrder);
パラメータ
- dx
x 軸方向の平行移動の値。 - dy
y 軸方向の平行移動の値。 - order
平行移動を適用する順序 (前または後)。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- 新しい LinearGradientBrush オブジェクトを作成します。
- このブラシを使用して、左から右へ線形に色が変化するグラデーションを持つ四角形を画面に描画します。
- LinearGradientBrush オブジェクトを 90 度回転し、グラデーションをスケールします。
- 回転され、グラデーションがスケールされた四角形を画面に描画します。
- 上から下へ線形グラデーションされるよう四角形を平行移動します。
- 画面に平行移動された四角形を描画します。
[Visual Basic, C#] 3 つの四角形が表示され、1 番上の四角形は左から右へのグラデーション、中央の四角形は回転およびスケールされたグラデーション、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# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
LinearGradientBrush クラス | LinearGradientBrush メンバ | System.Drawing.Drawing2D 名前空間 | LinearGradientBrush.TranslateTransform オーバーロードの一覧