Share via


ColorBlend Konstruktoren

Definition

Initialisiert eine neue Instanz der ColorBlend-Klasse.

Überlädt

ColorBlend()

Initialisiert eine neue Instanz der ColorBlend-Klasse.

ColorBlend(Int32)

Initialisiert eine neue Instanz der ColorBlend-Klasse mit der angegebenen Anzahl von Farben und Positionen.

ColorBlend()

Quelle:
ColorBlend.cs
Quelle:
ColorBlend.cs
Quelle:
ColorBlend.cs

Initialisiert eine neue Instanz der ColorBlend-Klasse.

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

Beispiele

Das folgende Beispiel ist für die Verwendung in einer Windows Forms-Umgebung vorgesehen. Es wird veranschaulicht, wie die ColorBlend -Klasse in Verbindung mit der LinearGradientBrush -Klasse verwendet wird, um eine Ellipse auf den Bildschirm zu zeichnen, bei der die Farben gemischt sind. Die Ellipse ist links grün, verschmilzt zu Gelb, dann zu Blau und schließlich zu Rot auf der rechten Seite. Dies wird durch die Einstellungen in den Arrays und myPositions erreicht, die myColors in den Colors Eigenschaften und Positions verwendet werden. Beachten Sie, dass die InterpolationColors Eigenschaft des LinearGradientBrush Objekts mit dem Namen lgBrush2 gleich dem ColorBlend -Objekt myBlendsein muss.

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

Gilt für:

ColorBlend(Int32)

Quelle:
ColorBlend.cs
Quelle:
ColorBlend.cs
Quelle:
ColorBlend.cs

Initialisiert eine neue Instanz der ColorBlend-Klasse mit der angegebenen Anzahl von Farben und Positionen.

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

Parameter

count
Int32

Die Anzahl der Farben und Positionen in diesem ColorBlend.

Beispiele

Ein Beispiel finden Sie unter ColorBlend

Gilt für: