Matrix.Scale 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
通过预先计算比例向量,将指定的比例向量应用到此 Matrix。
重载
Scale(Single, Single) |
通过预先计算比例向量,将指定的比例向量应用到此 Matrix。 |
Scale(Single, Single, MatrixOrder) |
使用指定的顺序,将指定的比例向量( |
Scale(Single, Single)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
通过预先计算比例向量,将指定的比例向量应用到此 Matrix。
public:
void Scale(float scaleX, float scaleY);
public void Scale (float scaleX, float scaleY);
member this.Scale : single * single -> unit
Public Sub Scale (scaleX As Single, scaleY As Single)
参数
示例
有关示例,请参见 Scale(Single, Single, MatrixOrder)。
适用于
Scale(Single, Single, MatrixOrder)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
使用指定的顺序,将指定的比例向量(scaleX
和 scaleY
)应用到此 Matrix。
public:
void Scale(float scaleX, float scaleY, System::Drawing::Drawing2D::MatrixOrder order);
public void Scale (float scaleX, float scaleY, System.Drawing.Drawing2D.MatrixOrder order);
member this.Scale : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Scale (scaleX As Single, scaleY As Single, order As MatrixOrder)
参数
- order
- MatrixOrder
一个 MatrixOrder,指定应用比例向量到此 Matrix 的顺序(追加或预先计算)。
示例
下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
事件Paint对象。 此代码执行以下操作:
在 (蓝色矩形) 应用缩放转换之前,将矩形绘制到屏幕。
创建一个矩阵,并在 x 轴上按 3 缩放,在 y 轴上按 2 缩放。
将此矩阵转换应用于矩形。
将转换后的矩形绘制到屏幕 (红色矩形) 。
请注意,红色矩形在 x 轴中缩放了 3,在 y 轴中缩放了 2,包括矩形的左上角 (矩形) 的起点。
public:
void ScaleExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
// Draw the rectangle to the screen before applying the
// transform.
e->Graphics->DrawRectangle( myPen, 50, 50, 100, 100 );
// Create a matrix and scale it.
Matrix^ myMatrix = gcnew 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 );
}
public void ScaleExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = 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.
Matrix myMatrix = 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);
}
Public Sub ScaleExample(ByVal 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
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈