ColorBlend クラスの新しいインスタンスを初期化します。
名前空間: System.Drawing.Drawing2D
アセンブリ: System.Drawing (system.drawing.dll 内)
構文
'宣言
Public Sub New
'使用
Dim instance As New ColorBlend
public ColorBlend ()
public:
ColorBlend ()
public ColorBlend ()
public function ColorBlend ()
使用例
Windows フォーム環境で使用するための例を次に示します。ColorBlend クラスを LinearGradientBrush クラスと組み合わせて使用し、ブレンドされた楕円を画面に描画する方法を示しています。この楕円は左側が緑で、色のブレンドによって黄色になってから青になり、最後に右側で赤になります。これは、Colors プロパティと Positions プロパティで使用される myColors 配列と myPositions 配列の設定によって行われます。lgBrush2 という名前の LinearGradientBrush オブジェクトの InterpolationColors プロパティは、ColorBlend オブジェクトの myBlend と等価になっている必要があります。
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
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:
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 void OnPaint(PaintEventArgs e)
{
//Draw ellipse using ColorBlend.
Point startPoint2 = new Point(20, 110);
Point endPoint2 = new Point(140, 110);
Color myColors[] = { Color.get_Green(), Color.get_Yellow(),
Color.get_Yellow(), Color.get_Blue(),
Color.get_Red(), Color.get_Red() };
float myPositions[] = { 0.0F, 0.2F, 0.4F, 0.6F, 0.8F, 1.0F };
ColorBlend myBlend = new ColorBlend();
myBlend.set_Colors(myColors);
myBlend.set_Positions(myPositions);
LinearGradientBrush lgBrush2 = new LinearGradientBrush(startPoint2,
endPoint2, Color.get_Green(), Color.get_Red());
lgBrush2.set_InterpolationColors(myBlend);
Rectangle ellipseRect2 = new Rectangle(20, 110, 120, 80);
e.get_Graphics().FillEllipse(lgBrush2, ellipseRect2);
} //OnPaint
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0