Прочетете на английски Редактиране

Споделяне чрез


ColorBlend Constructors

Definition

Initializes a new instance of the ColorBlend class.

Overloads

ColorBlend()

Initializes a new instance of the ColorBlend class.

ColorBlend(Int32)

Initializes a new instance of the ColorBlend class with the specified number of colors and positions.

ColorBlend()

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

Initializes a new instance of the ColorBlend class.

C#
public ColorBlend();

Examples

The following example is intended to be used in a Windows Forms environment. It demonstrates how to use the ColorBlend class in conjunction with the LinearGradientBrush class to draw an ellipse to screen that has its colors blended. The ellipse is green on the left, blends to yellow, then to blue, and finally to red on the right. This is accomplished through the settings in the myColors and myPositions arrays used in the Colors and Positions properties. Note that the InterpolationColors property of the LinearGradientBrush object named lgBrush2 must be made equal to the ColorBlend object myBlend.

C#
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);
}

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ColorBlend(Int32)

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

Initializes a new instance of the ColorBlend class with the specified number of colors and positions.

C#
public ColorBlend(int count);

Parameters

count
Int32

The number of colors and positions in this ColorBlend.

Examples

For an example see ColorBlend

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10