次の方法で共有


PathGradientBrush.ScaleTransform メソッド (Single, Single, MatrixOrder)

指定した順序で、指定した分量だけローカル ジオメトリック変換をスケールします。

Overloads Public Sub ScaleTransform( _
   ByVal sx As Single, _   ByVal sy As Single, _   ByVal order As MatrixOrder _)
[C#]
public void ScaleTransform(floatsx,floatsy,MatrixOrderorder);
[C++]
public: void ScaleTransform(floatsx,floatsy,MatrixOrderorder);
[JScript]
public function ScaleTransform(
   sx : float,sy : float,order : MatrixOrder);

パラメータ

  • sx
    x 軸方向の変換スケール係数。
  • sy
    y 軸方向の変換スケール係数。
  • order
    スケール行列を後に適用するか、前に適用するかを指定する MatrixOrder 列挙体。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • グラフィックス パスを作成し、そのパスに四角形を追加します。
  • パスを形成する複数の点から PathGradientBrush オブジェクトを作成します。この例では、これらの点は四角形を形成していますが、どのような図形を形成する点でもかまいません。
  • 中心の色を赤に設定し、周囲の色を青に設定します。
  • スケール変換を適用する前に、 PathGradientBrush を画面に描画します。
  • ブラシの ScaleTransform メソッドを使用して、そのブラシにスケール変換を適用します。
  • TranslateTransform メソッドを呼び出して、画面に先に描画された四角形と重複しないように、ブラシ四角形を移動します。
  • 平行移動後のブラシの四角形を画面に描画します。

[Visual Basic, C#] 下側の四角形は、平行移動前に描画された四角形と比較して、x 軸方向の辺の長さが 2 倍になっています。

 
Public Sub ScaleTransformExample(e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath()
Dim rect As New Rectangle(100, 20, 100, 50)
myPath.AddRectangle(rect)
' Get the path's array of points.
Dim myPathPointArray As PointF() = myPath.PathPoints
' Create a path gradient brush.
Dim myPGBrush As New PathGradientBrush(myPathPointArray)
' Set the color span.
myPGBrush.CenterColor = Color.Red
Dim mySurroundColor As Color() = {Color.Blue}
myPGBrush.SurroundColors = mySurroundColor
' Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Scale by a factor of 2 in the x-axis by applying the scale
' transform to the brush.
myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append)
' Move the brush down by 100 by Applying the translate
' transform to the brush.
myPGBrush.TranslateTransform(- 100, 100, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub
        
[C#] 
public void ScaleTransformExample(PaintEventArgs e)
{
// Create a graphics path and add a rectangle.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(100, 20, 100, 50);
myPath.AddRectangle(rect);
// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;
// Create a path gradient brush.
PathGradientBrush myPGBrush = new
PathGradientBrush(myPathPointArray);
// Set the color span.
myPGBrush.CenterColor = Color.Red;
Color[] mySurroundColor = {Color.Blue};
myPGBrush.SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Scale by a factor of 2 in the x-axis by applying the scale
// transform to the brush.
myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append);
// Move the brush down by 100 by Applying the translate
// transform to the brush.
myPGBrush.TranslateTransform(-100, 100, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
        

[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 ファミリ

参照

PathGradientBrush クラス | PathGradientBrush メンバ | System.Drawing.Drawing2D 名前空間 | PathGradientBrush.ScaleTransform オーバーロードの一覧