PathGradientBrush.ScaleTransform 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。
重载
ScaleTransform(Single, Single) |
按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。 |
ScaleTransform(Single, Single, MatrixOrder) |
按指定顺序按指定量缩放局部几何转换。 |
ScaleTransform(Single, Single)
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
按指定量缩放局部几何转换。 此方法将缩放矩阵追加到转换之前。
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)
参数
- sx
- Single
x 轴方向的转换刻度因子。
- sy
- Single
y 轴方向的转换刻度因子。
示例
有关示例,请参阅 ScaleTransform。
适用于
ScaleTransform(Single, Single, MatrixOrder)
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
按指定顺序按指定量缩放局部几何转换。
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)
参数
- sx
- Single
x 轴方向的转换刻度因子。
- sy
- Single
y 轴方向的转换刻度因子。
- order
- MatrixOrder
一个 MatrixOrder,指定是追加还是追加缩放矩阵。
示例
下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgse
OnPaint 事件对象。 代码
创建图形路径并为其添加一个矩形。
从路径点创建 PathGradientBrush(在此示例中,这些点构成矩形,但它可以是大多数形状)。
将中心颜色设置为红色,将周围颜色设置为蓝色。
在应用缩放转换之前,将 PathGradientBrush 绘制到屏幕。
使用其 ScaleTransform 方法将缩放转换应用于画笔。
调用 TranslateTransform 方法移动画笔矩形,使其不会覆盖前面绘制到屏幕的画笔矩形。
将翻译的画笔矩形绘制到屏幕。
请注意,底部矩形在 x 轴中长两倍,与在翻译前绘制的矩形相同。
public:
void ScaleTransformExample( PaintEventArgs^ e )
{
// Create a graphics path and add a rectangle.
GraphicsPath^ myPath = gcnew GraphicsPath;
Rectangle rect = Rectangle(100,20,100,50);
myPath->AddRectangle( rect );
// Get the path's array of points.
array<PointF>^myPathPointArray = myPath->PathPoints;
// Create a path gradient brush.
PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );
// Set the color span.
myPGBrush->CenterColor = Color::Red;
array<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 );
}
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);
}
Public Sub ScaleTransformExample(ByVal 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