ColorBlend 构造函数

定义

初始化 ColorBlend 类的新实例。

重载

ColorBlend()

初始化 ColorBlend 类的新实例。

ColorBlend(Int32)

使用指定的颜色和位置的数目初始化 ColorBlend 类的新实例。

ColorBlend()

Source:
ColorBlend.cs
Source:
ColorBlend.cs
Source:
ColorBlend.cs

初始化 ColorBlend 类的新实例。

public:
 ColorBlend();
public ColorBlend ();
Public Sub New ()

示例

以下示例旨在用于Windows 窗体环境。 它演示了 ColorBlend 如何将 类与 LinearGradientBrush 类结合使用,将椭圆绘制到混合了颜色的屏幕上。 椭圆左侧是绿色的,混合到黄色,然后混合到蓝色,最后混合到右侧的红色。 这可以通过 和 属性中使用的 和 myPositions 数组中的PositionsColors设置myColors来实现。 请注意,InterpolationColors名为 lgBrush2LinearGradientBrush 对象的 属性必须与 对象 myBlend相等ColorBlend

protected:
   virtual void OnPaint( PaintEventArgs^ e ) override
   {
      //Draw ellipse using ColorBlend.
      Point startPoint2 = Point(20,110);
      Point endPoint2 = Point(140,110);
      array<Color>^ myColors =
            {Color::Green,Color::Yellow,Color::Yellow,Color::Blue,Color::Red,Color::Red};
      array<Single>^myPositions = {0.0f,.20f,.40f,.60f,.80f,1.0f};
      ColorBlend^ myBlend = gcnew ColorBlend;
      myBlend->Colors = myColors;
      myBlend->Positions = myPositions;
      LinearGradientBrush^ lgBrush2 =
            gcnew LinearGradientBrush( startPoint2,endPoint2,Color::Green,Color::Red );
      lgBrush2->InterpolationColors = myBlend;
      Rectangle ellipseRect2 = Rectangle(20,110,120,80);
      e->Graphics->FillEllipse( lgBrush2, ellipseRect2 );
   }
protected override void OnPaint(PaintEventArgs e)
{
             
    //Draw ellipse using ColorBlend.
    Point startPoint2 = new Point(20, 110);
    Point endPoint2 = new Point(140, 110);
    Color[] myColors = {Color.Green,
                           Color.Yellow,
                           Color.Yellow,
                           Color.Blue,
                           Color.Red,
                           Color.Red};
    float[] myPositions = {0.0f,.20f,.40f,.60f,.80f,1.0f};
    ColorBlend myBlend = new ColorBlend();
    myBlend.Colors = myColors;
    myBlend.Positions = myPositions;
    LinearGradientBrush lgBrush2 = new LinearGradientBrush(startPoint2,
        endPoint2,
        Color.Green,
        Color.Red);
    lgBrush2.InterpolationColors = myBlend;
    Rectangle ellipseRect2 = new Rectangle(20, 110, 120, 80);
    e.Graphics.FillEllipse(lgBrush2, ellipseRect2);
}
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    ' Draw ellipse using ColorBlend.
    Dim startPoint2 As New Point(20, 110)
    Dim endPoint2 As New Point(140, 110)
    Dim myColors As Color() = {Color.Green, Color.Yellow, _
    Color.Yellow, Color.Blue, Color.Red, Color.Red}
    Dim myPositions As Single() = {0.0F, 0.2F, 0.4F, 0.6F, 0.8F, 1.0F}
    Dim myBlend As New ColorBlend
    myBlend.Colors = myColors
    myBlend.Positions = myPositions
    Dim lgBrush2 As New LinearGradientBrush(startPoint2, endPoint2, _
    Color.Green, Color.Red)
    lgBrush2.InterpolationColors = myBlend
    Dim ellipseRect2 As New Rectangle(20, 110, 120, 80)
    e.Graphics.FillEllipse(lgBrush2, ellipseRect2)
End Sub

适用于

ColorBlend(Int32)

Source:
ColorBlend.cs
Source:
ColorBlend.cs
Source:
ColorBlend.cs

使用指定的颜色和位置的数目初始化 ColorBlend 类的新实例。

public:
 ColorBlend(int count);
public ColorBlend (int count);
new System.Drawing.Drawing2D.ColorBlend : int -> System.Drawing.Drawing2D.ColorBlend
Public Sub New (count As Integer)

参数

count
Int32

在此 ColorBlend 中颜色和位置的数目。

示例

有关示例,请参阅 ColorBlend

适用于