PathGradientBrush.SetSigmaBellShape 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
基于一个钟形曲线创建中心色和第一种周围色之间的渐变过渡。
重载
SetSigmaBellShape(Single) |
创建一个从路径中心开始向路径边界更改颜色的渐变画笔。 从一种颜色向另一种颜色的转换基于一个钟形曲线。 |
SetSigmaBellShape(Single, Single) |
创建一个从路径中心开始向路径边界更改颜色的渐变画笔。 从一种颜色向另一种颜色的转换基于一个钟形曲线。 |
SetSigmaBellShape(Single)
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
创建一个从路径中心开始向路径边界更改颜色的渐变画笔。 从一种颜色向另一种颜色的转换基于一个钟形曲线。
public:
void SetSigmaBellShape(float focus);
public void SetSigmaBellShape (float focus);
member this.SetSigmaBellShape : single -> unit
Public Sub SetSigmaBellShape (focus As Single)
参数
- focus
- Single
介于 0 和 1 之间的一个值,它指定沿路径中心到路径边界的任意半径向上中心色亮度最高的位置。 1(默认值)使最高亮度位于路径中心。
示例
有关示例,请参见 SetSigmaBellShape。
注解
如果数组中 SurroundColors 有多个颜色,则数组中的第一种颜色将用于结束颜色。 此数组中指定的颜色是用于画笔边界路径上的离散点的颜色。
默认情况下,从路径渐变的边界移动到中心点时,颜色会逐渐从边界颜色更改为中心颜色。 可以通过调用此方法自定义边界和中心颜色的定位和混合。
适用于
SetSigmaBellShape(Single, Single)
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
- Source:
- PathGradientBrush.cs
创建一个从路径中心开始向路径边界更改颜色的渐变画笔。 从一种颜色向另一种颜色的转换基于一个钟形曲线。
public:
void SetSigmaBellShape(float focus, float scale);
public void SetSigmaBellShape (float focus, float scale);
member this.SetSigmaBellShape : single * single -> unit
Public Sub SetSigmaBellShape (focus As Single, scale As Single)
参数
- focus
- Single
介于 0 和 1 之间的一个值,它指定沿路径中心到路径边界的任意半径向上中心色亮度最高的位置。 1(默认值)使最高亮度位于路径中心。
- scale
- Single
介于 0 和 1 之间的一个值,它指定与边界色混合的中心色的最高亮度。 1 导致中心色的最高可能亮度,并且它是默认值。
示例
下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
事件OnPaint对象。 此代码执行以下操作:
创建图形路径并向其中添加一个矩形。
PathGradientBrush在此示例中,从路径点 (创建 ,这些点构成一个矩形,但它可以是大多数) 的任何形状。
将中心颜色设置为红色,将周围颜色设置为蓝色。
PathGradientBrush在应用混合转换之前将 绘制到屏幕。
使用 SetSigmaBellShape 画笔的 方法将混合转换应用于画笔。
TranslateTransform调用 方法来移动画笔矩形,使其不会覆盖之前绘制到屏幕的矩形。
将转换后的画笔矩形绘制到屏幕。
请注意,红色) (最大中心颜色位于路径中心到路径边界的一半处。
public:
void SetSigmaBellShapeExample( 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 blend.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );
// Set the Blend factors and transform the brush.
myPGBrush->SetSigmaBellShape( 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 setting the
// blend and applying the transform.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
}
public void SetSigmaBellShapeExample(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 blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Set the Blend factors and transform the brush.
myPGBrush.SetSigmaBellShape(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 setting the
// blend and applying the transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub SetSigmaBellShapeExample(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.SetSigmaBellShape(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 setting the
' blend and applying the transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub
注解
如果数组中 SurroundColors 有多个颜色,则数组中的第一种颜色将用于结束颜色。 此数组中指定的颜色是用于画笔边界路径上的离散点的颜色。
默认情况下,从路径渐变的边界移动到中心点时,颜色会逐渐从边界颜色更改为中心颜色。 可以通过调用此方法自定义边界和中心颜色的定位和混合。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈