PathGradientBrush.SetSigmaBellShape 方法

定义

基于一个钟形曲线创建中心色和第一种周围色之间的渐变过渡。Creates a gradient falloff between the center color and the first surrounding color based on a bell-shaped curve.

重载

SetSigmaBellShape(Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

SetSigmaBellShape(Single, Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

SetSigmaBellShape(Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

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 之间的一个值,它指定沿路径中心到路径边界的任意半径向上中心色亮度最高的位置。A value from 0 through 1 that specifies where, along any radial from the center of the path to the path's boundary, the center color will be at its highest intensity. 1(默认值)使最高亮度位于路径中心。A value of 1 (the default) places the highest intensity at the center of the path.

示例

有关示例,请参阅SetSigmaBellShapeFor an example, see SetSigmaBellShape.

注解

如果 SurroundColors 数组中有多个颜色,则使用数组中的第一种颜色作为结束颜色。If there is more than one color in the SurroundColors array, the first color in the array is used for the ending color. 此数组中指定的颜色是画笔边界路径上的离散点所使用的颜色。The colors specified in this array are colors used for discrete points on the brush's boundary path.

默认情况下,当你从路径渐变的边界移到中心点时,颜色将从边界逐渐变为中心色。By default, as you move from the boundary of a path gradient to the center point, the color changes gradually from the boundary color to the center color. 通过调用此方法,可以自定义边界和中心色的定位和混合。You can customize the positioning and blending of the boundary and center colors by calling this method.

SetSigmaBellShape(Single, Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

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 之间的一个值,它指定沿路径中心到路径边界的任意半径向上中心色亮度最高的位置。A value from 0 through 1 that specifies where, along any radial from the center of the path to the path's boundary, the center color will be at its highest intensity. 1(默认值)使最高亮度位于路径中心。A value of 1 (the default) places the highest intensity at the center of the path.

scale
Single

介于 0 和 1 之间的一个值,它指定与边界色混合的中心色的最高亮度。A value from 0 through 1 that specifies the maximum intensity of the center color that gets blended with the boundary color. 1 导致中心色的最高可能亮度,并且它是默认值。A value of 1 causes the highest possible intensity of the center color, and it is the default value.

示例

下面的代码示例是为与 Windows 窗体一起使用而设计的,它需要 PaintEventArgseOnPaint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. 该代码执行下列操作:The code performs the following actions:

  • 创建图形路径并向其添加一个矩形。Creates a graphics path and adds a rectangle to it.

  • 从路径点创建一个 PathGradientBrush (在此示例中,点构成一个矩形,但它可以是大多数形状)。Creates a PathGradientBrush from the path points (in this example, the points form a rectangle, but it could be most any shape).

  • 将中间颜色设置为红色,将周围颜色设置为蓝色。Sets the center color to red and the surrounding color to blue.

  • 在应用 blend 变换之前,将 PathGradientBrush 绘制到屏幕。Draws the PathGradientBrush to the screen prior to applying the blend transform.

  • 使用混合转换将其 SetSigmaBellShape 方法应用于画笔。Applies the blend transform to the brush by using its SetSigmaBellShape method.

  • 调用 TranslateTransform 方法来移动画笔矩形,使其不会覆盖之前绘制到屏幕的画笔。Calls the TranslateTransform method to move the brush rectangle such that it does not overlay the one drawn to the screen earlier.

  • 将变换画笔矩形绘制到屏幕上。Draws the transformed-brush rectangle to the screen.

请注意,最大中心颜色(红色)从路径中心到路径边界的半个位置。Notice that the maximum center color (red) is located half way from the center of the path to the path boundary.

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 数组中有多个颜色,则使用数组中的第一种颜色作为结束颜色。If there is more than one color in the SurroundColors array, the first color in the array is used for the ending color. 此数组中指定的颜色是画笔边界路径上的离散点所使用的颜色。The colors specified in this array are colors used for discrete points on the brush's boundary path.

默认情况下,当你从路径渐变的边界移到中心点时,颜色将从边界逐渐变为中心色。By default, as you move from the boundary of a path gradient to the center point, the color changes gradually from the boundary color to the center color. 通过调用此方法,可以自定义边界和中心色的定位和混合。You can customize the positioning and blending of the boundary and center colors by calling this method.

适用于