LinearGradientBrush.SetSigmaBellShape 方法

定义

基于钟形曲线创建渐变下降。

重载

SetSigmaBellShape(Single)

基于钟形曲线创建渐变下降。

SetSigmaBellShape(Single, Single)

基于钟形曲线创建渐变下降。

SetSigmaBellShape(Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.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 的值,该值指定渐变的中心(起始颜色和结束颜色的点相等)。

示例

有关示例,请参阅 SetSigmaBellShape.

注解

此方法指定一个 focus,即渐变仅由结束颜色构成的点。 focus 参数将一个位置表示为沿渐变线距离的比例。 渐变根据钟曲线形状(正态分布)下降到两侧的起始颜色。

适用于

SetSigmaBellShape(Single, Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.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 的值,该值指定渐变的中心(渐变仅由结束颜色构成的点)。

scale
Single

一个介于 0 到 1 的值,该值指定颜色从 focus下降的速度。

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建新的 LinearGradientBrush

  • 使用此画笔向屏幕绘制椭圆,该屏幕具有颜色的线性、从左到右的切换效果。

  • LinearGradientBrush 转换为钟形曲线,其峰值在中心。

  • 使用钟形画笔将第二个椭圆绘制到屏幕。

请注意,下椭圆的渐变从蓝色过渡到红色,然后转换回蓝色。

private:
   void SetSigmaBellShapeExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );

      // Draw an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, myRect );

      // Create a bell-shaped brush with the peak at the
      // center of the drawing area.
      myLGBrush->SetSigmaBellShape( .5f, 1.0f );

      // Use the bell- shaped brush to draw a second
      // ellipse.
      myRect.Y = 150;
      e->Graphics->FillEllipse( myLGBrush, myRect );
   }
private void SetSigmaBellShapeExample(PaintEventArgs e)
{
             
    // Create a LinearGradientBrush.
    Rectangle myRect = new Rectangle(20, 20, 200, 100);
    LinearGradientBrush myLGBrush = new LinearGradientBrush(
        myRect, Color.Blue, Color.Red,  0.0f, true);
             
    // Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect);
             
    // Create a bell-shaped brush with the peak at the
             
    // center of the drawing area.
    myLGBrush.SetSigmaBellShape(.5f, 1.0f);
             
    // Use the bell- shaped brush to draw a second
    // ellipse.
    myRect.Y = 150;
    e.Graphics.FillEllipse(myLGBrush, myRect);
}
Public Sub SetSigmaBellShapeExample(ByVal e As PaintEventArgs)

    ' Create a LinearGradientBrush.
    Dim myRect As New Rectangle(20, 20, 200, 100)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Red, 0.0F, True)

    ' Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect)

    ' Create a triangular shaped brush with the peak at the center
    ' of the drawing area.
    myLGBrush.SetSigmaBellShape(0.5F, 1.0F)

    ' Use the triangular brush to draw a second ellipse.
    myRect.Y = 150
    e.Graphics.FillEllipse(myLGBrush, myRect)
End Sub

注解

此方法指定一个 focus,即渐变仅由结束颜色构成的点。 focus 参数将一个位置表示为沿渐变线距离的比例。 渐变根据钟曲线形状(正态分布)下降到两侧的起始颜色。

适用于