Graphics.ResetTransform メソッド
対象の Graphics オブジェクトのワールド変換行列を単位行列にリセットします。
Public Sub ResetTransform()
[C#]
public void ResetTransform();
[C++]
public: void ResetTransform();
[JScript]
public function ResetTransform();
戻り値
このメソッドは値を返しません。
解説
単位行列は、スケーリング、回転、および平行移動を行わない変換を表します。対象の Graphics オブジェクトのワールド変換を単位行列にリセットした場合、そのワールド変換では変換した項目のジオメトリは変更されません。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードでは次のアクションを実行します。
- ベクタ (100, 0) で Windows フォームのワールド変換を平行移動します。
- フォームのグラフィックスの状態を保存します。
- フォームのワールド変換を単位行列にリセットし、四角形を赤いソリッド ブラシで塗りつぶします。
- 平行移動したグラフィックスの状態を復元し、四角形を青いソリッド ブラシで塗りつぶします。
[Visual Basic, C#] 赤で塗りつぶされた平行移動していない四角形と、青で塗りつぶされた平行移動済みの四角形が生成されます。
Public Sub SaveRestore(e As PaintEventArgs)
' Translate transformation matrix.
e.Graphics.TranslateTransform(100, 0)
' Save translated graphics state.
Dim transState As GraphicsState = e.Graphics.Save()
' Reset transformation matrix to identity and fill rectangle.
e.Graphics.ResetTransform()
e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0, 100, 100)
' Restore graphics state to translated state and fill second
' rectangle.
e.Graphics.Restore(transState)
e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
100, 100)
End Sub
[C#]
public void SaveRestore(PaintEventArgs e)
{
// Translate transformation matrix.
e.Graphics.TranslateTransform(100, 0);
// Save translated graphics state.
GraphicsState transState = e.Graphics.Save();
// Reset transformation matrix to identity and fill rectangle.
e.Graphics.ResetTransform();
e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 100, 100);
// Restore graphics state to translated state and fill second rectangle.
e.Graphics.Restore(transState);
e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 100, 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 ファミリ