PathGradientBrush.SetBlendTriangularShape Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Создает градиент с цветом центра и линейным переходом к одному окружающему цвету.
Перегрузки
SetBlendTriangularShape(Single) |
Создает градиент с цветом центра и линейным переходом к одному окружающему цвету. |
SetBlendTriangularShape(Single, Single) |
Создает градиент с цветом центра и линейным переходом к каждому из окружающих цветов. |
SetBlendTriangularShape(Single)
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
Создает градиент с цветом центра и линейным переходом к одному окружающему цвету.
public:
void SetBlendTriangularShape(float focus);
public void SetBlendTriangularShape (float focus);
member this.SetBlendTriangularShape : single -> unit
Public Sub SetBlendTriangularShape (focus As Single)
Параметры
- focus
- Single
Значение от 0 до 1, определяющее, в какой позиции вдоль любого луча из центра контура к его границе интенсивность центрального цвета будет максимальной. Значение 1 (по умолчанию) помещает максимальную интенсивность в центр контура.
Примеры
Пример см. в разделе SetBlendTriangularShape.
Комментарии
Если в SurroundColors массиве несколько цветов, для конечного цвета используется первый цвет в массиве. Цвета, указанные в этом массиве, используются для дискретных точек на пути границы кисти.
Применяется к
SetBlendTriangularShape(Single, Single)
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
- Исходный код:
- PathGradientBrush.cs
Создает градиент с цветом центра и линейным переходом к каждому из окружающих цветов.
public:
void SetBlendTriangularShape(float focus, float scale);
public void SetBlendTriangularShape (float focus, float scale);
member this.SetBlendTriangularShape : single * single -> unit
Public Sub SetBlendTriangularShape (focus As Single, scale As Single)
Параметры
- focus
- Single
Значение от 0 до 1, определяющее, в какой позиции вдоль любого луча из центра контура к его границе интенсивность центрального цвета будет максимальной. Значение 1 (по умолчанию) помещает максимальную интенсивность в центр контура.
- scale
- Single
Значение от 0 до 1, определяющее максимальную интенсивность центрального цвета, которая смешивается с граничным цветом. Значение 1 соответствует максимально возможной интенсивности центрального цвета — оно установлено по умолчанию.
Примеры
Следующий пример кода предназначен для использования с Windows Forms, и для него требуется PaintEventArgse
OnPaint объект события . Код выполняет следующие действия.
Создает графический путь и добавляет к нему прямоугольник.
PathGradientBrush Создает из точек пути (в этом примере точки образуют прямоугольник, но это может быть любая форма).
Задает для центрального цвета красный, а для окружающего — синий.
Рисует на PathGradientBrush экране перед применением преобразования смешения.
Применяет преобразование смешения к кисти с помощью метода SetBlendTriangularShape .
TranslateTransform Вызывает метод для перемещения прямоугольника кисти таким образом, чтобы он не накладывал нарисованный ранее на экране.
Рисует преобразованный прямоугольник кисти, нарисованный на экране.
Обратите внимание, что максимальный цвет центра (красный) находится на полпути от центра пути до границы пути.
public:
void SetBlendTriangularShapeExample( 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 the blend.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );
// Set the Blend factors.
myPGBrush->SetBlendTriangularShape( 0.5f, 1.0f );
// Move the brush down by 100 by Applying the translate
// transform to the brush.
myPGBrush->TranslateTransform( 0, 100, MatrixOrder::Append );
// Draw the brush to the screen again after applying the
// transforms.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
}
public void SetBlendTriangularShapeExample(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 the blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Set the Blend factors.
myPGBrush.SetBlendTriangularShape(0.5f, 1.0f);
// Move the brush down by 100 by Applying the translate
// transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub SetBlendTriangularShapeExample(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 blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Set the Blend factors.
myPGBrush.SetBlendTriangularShape(0.5F, 1.0F)
' Move the brush down by 100 by Applying the translate
' transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub
Комментарии
Если в SurroundColors массиве несколько цветов, для конечного цвета используется первый цвет в массиве. Цвета, указанные в этом массиве, являются цветами, используемыми для дискретных точек на пути границы кисти.
По умолчанию при переходе от границы градиента пути к центральной точке цвет постепенно меняется от цвета границы к центру. Вы можете настроить расположение и смешивание цветов границы и центра, вызвав этот метод.
Применяется к
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по