Matrix.Scale Method
See Also
Matrix Class | Matrix Members | System.Drawing.Drawing2D Namespace | Managed Extensions for C++ Programming
Language
C#
C++
JScript
Visual Basic
Show All
Applies the specified scale vector to this Matrix object by prepending the scale vector.
Overload List
Applies the specified scale vector to this Matrix object by prepending the scale vector.
[Visual Basic] Overloads Public Sub Scale(Single, Single)
[C#] public void Scale(float, float);
[C++] public: void Scale(float, float);
[JScript] public function Scale(float, float);
Applies the specified scale vector (scaleX and scaleY) to this Matrix object using the specified order.
[Visual Basic] Overloads Public Sub Scale(Single, Single, MatrixOrder)
[C#] public void Scale(float, float, MatrixOrder);
[C++] public: void Scale(float, float, MatrixOrder);
[JScript] public function Scale(float, float, MatrixOrder);
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:
Draws a rectangle to the screen prior to applying a scaling transform (the blue rectangle).
Creates a matrix and scales it by 3 in the x-axis and 2 in the y-axis.
Applies this matrix transform to the rectangle.
Draws the transformed rectangle to the screen (the red rectangle).
[Visual Basic, C#] Notice that the red rectangle has been scaled by a factor of 3 in the x-axis and by 2 in the y-axis, including the upper left-hand corner of the rectangle (the beginning point of the rectangle).
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Scale. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Public Sub ScaleExample(e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
' Draw the rectangle to the screen before applying the
' transform.
e.Graphics.DrawRectangle(myPen, 50, 50, 100, 100)
' Create a matrix and scale it.
Dim myMatrix As New Matrix()
myMatrix.Scale(3, 2, MatrixOrder.Append)
' Draw the rectangle to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 50, 50, 100, 100)
End Sub
Regards,
Dr M.