PathGradientBrush.ScaleTransform Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Масштабирует локальное геометрическое преобразование на заданные величины. Этот метод добавляет в преобразование масштабирующую матрицу.
Перегрузки
ScaleTransform(Single, Single) |
Масштабирует локальное геометрическое преобразование на заданные величины. Этот метод добавляет в преобразование масштабирующую матрицу. |
ScaleTransform(Single, Single, MatrixOrder) |
Масштабирует локальное геометрическое преобразование на заданные величины в указанном порядке. |
ScaleTransform(Single, Single)
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- 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)
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- 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 Forms, и для него требуется 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
Применяется к
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по