ColorBlend Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Initializes a new instance of the ColorBlend class.
public:
ColorBlend();
public ColorBlend ();
Public Sub New ()
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
.
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
Applies to
ColorBlend(Int32)
- 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.
public:
ColorBlend(int count);
public ColorBlend (int count);
new System.Drawing.Drawing2D.ColorBlend : int -> System.Drawing.Drawing2D.ColorBlend
Public Sub New (count As Integer)
Parameters
- count
- Int32
The number of colors and positions in this ColorBlend.
Examples
For an example see ColorBlend
Applies to
.NET