Graphics.ScaleTransform Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
Overloads
ScaleTransform(Single, Single) |
Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix. |
ScaleTransform(Single, Single, MatrixOrder) |
Applies the specified scaling operation to the transformation matrix of this Graphics in the specified order. |
ScaleTransform(Single, Single)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
public:
void ScaleTransform(float sx, float sy);
public void ScaleTransform (float sx, float sy);
member this.ScaleTransform : single * single -> unit
Public Sub ScaleTransform (sx As Single, sy As Single)
Parameters
- sx
- Single
Scale factor in the x direction.
- sy
- Single
Scale factor in the y direction.
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler. The code performs the following actions:
Rotates the world transformation matrix of the Windows Form by 30 degrees.
Scales that matrix by a factor of 3 in the x direction and a factor of 1 in the y direction by prepending the scaling transformation.
Draws a scaled, rotated rectangle with a blue pen.
The result is still a rectangle.
public:
void ScaleTransformFloat( PaintEventArgs^ e )
{
// Set world transform of graphics object to rotate.
e->Graphics->RotateTransform( 30.0F );
// Then to scale, prepending to world transform.
e->Graphics->ScaleTransform( 3.0F, 1.0F );
// Draw scaled, rotated rectangle to screen.
e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
}
private void ScaleTransformFloat(PaintEventArgs e)
{
// Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30.0F);
// Then to scale, prepending to world transform.
e.Graphics.ScaleTransform(3.0F, 1.0F);
// Draw scaled, rotated rectangle to screen.
e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloat(ByVal e As PaintEventArgs)
' Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30.0F)
' Then to scale, prepending to world transform.
e.Graphics.ScaleTransform(3.0F, 1.0F)
' Draw scaled, rotated rectangle to screen.
e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub
Remarks
The scaling operation consists of multiplying the transformation matrix by a diagonal matrix whose elements are (sx
, sy
, 1). This method prepends the transformation matrix of the Graphics by the scaling matrix.
Applies to
ScaleTransform(Single, Single, MatrixOrder)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
Applies the specified scaling operation to the transformation matrix of this Graphics in the specified order.
public:
void ScaleTransform(float sx, float sy, System::Drawing::Drawing2D::MatrixOrder order);
public void ScaleTransform (float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order);
member this.ScaleTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub ScaleTransform (sx As Single, sy As Single, order As MatrixOrder)
Parameters
- sx
- Single
Scale factor in the x direction.
- sy
- Single
Scale factor in the y direction.
- order
- MatrixOrder
Member of the MatrixOrder enumeration that specifies whether the scaling operation is prepended or appended to the transformation matrix.
Examples
The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler. The code performs the following actions:
Rotates the world transformation matrix of the Windows Form by 30 degrees.
Scales that matrix by a factor of 3 in the x direction and a factor of 1 in the y direction by appending the scaling transformation with the Append member.
Draws a rotated, scaled rectangle with a blue pen.
The result is a parallelogram.
public:
void ScaleTransformFloatMatrixOrder( PaintEventArgs^ e )
{
// Set world transform of graphics object to rotate.
e->Graphics->RotateTransform( 30.0F );
// Then to scale, appending to world transform.
e->Graphics->ScaleTransform( 3.0F, 1.0F, MatrixOrder::Append );
// Draw rotated, scaled rectangle to screen.
e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
}
private void ScaleTransformFloatMatrixOrder(PaintEventArgs e)
{
// Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30.0F);
// Then to scale, appending to world transform.
e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append);
// Draw rotated, scaled rectangle to screen.
e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloatMatrixOrder(ByVal e As PaintEventArgs)
' Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30.0F)
' Then to scale, appending to world transform.
e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append)
' Draw rotated, scaled rectangle to screen.
e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub
Remarks
The scaling operation consists of multiplying the transformation matrix by a diagonal matrix whose elements are (sx
, sy
, 1). This method prepends or appends the transformation matrix of the Graphics by the scaling matrix according to the order
parameter.