Blend.Positions プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)

/** @property */ public float[] get_Positions () /** @property */ public void set_Positions (float[] value)
グラデーション ラインに沿って距離の割合を指定するブレンド位置の配列。

この配列の要素によって、グラデーション ラインに沿った距離の割合が指定されます。たとえば、要素の値が 0.2f の場合は、開始位置から全距離の 20% の位置であることが指定されます。この配列の要素は、0.0f ~ 1.0f の浮動小数点値で表されます。配列の最初の要素は 0.0f、最後の要素は 1.0f になっている必要があります。

Factors プロパティと Positions プロパティを設定して、Blend クラスを使用するコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされています。System.Drawing.Drawing2D 名前空間がインポートされているフォームにコードを貼り付けます。フォームの Paint イベントを処理し、DemonstrateBlend メソッドを呼び出し、e を PaintEventArgs 値として渡します。
Private Sub DemonstrateBlend(ByVal e As PaintEventArgs) Dim blend1 As New Blend(9) ' Set the values in the Factors array to be all green, ' go to all blue, and then go back to green. blend1.Factors = New Single() {0.0F, 0.2F, 0.5F, 0.7F, 1.0F, _ 0.7F, 0.5F, 0.2F, 0.0F} ' Set the positions. blend1.Positions = New Single() {0.0F, 0.1F, 0.3F, 0.4F, 0.5F, _ 0.6F, 0.7F, 0.8F, 1.0F} ' Declare a rectangle to draw the Blend in. Dim rectangle1 As New Rectangle(10, 10, 120, 100) ' Create a new LinearGradientBrush using the rectangle, ' green and blue. and 90-degree angle. Dim brush1 As New LinearGradientBrush(rectangle1, _ Color.LightGreen, Color.Blue, 90, True) ' Set the Blend property on the brush to the custom blend. brush1.Blend = blend1 ' Fill in an ellipse with the brush. e.Graphics.FillEllipse(brush1, rectangle1) ' Dispose of the custom brush. brush1.Dispose() End Sub
private void DemonstrateBlend(PaintEventArgs e) { Blend blend1 = new Blend(9); // Set the values in the Factors array to be all green, // go to all blue, and then go back to green. blend1.Factors = new float[]{0.0F, 0.2F, 0.5F, 0.7F, 1.0F, 0.7F, 0.5F, 0.2F, 0.0F}; // Set the positions. blend1.Positions = new float[]{0.0F, 0.1F, 0.3F, 0.4F, 0.5F, 0.6F, 0.7F, 0.8F, 1.0F}; // Declare a rectangle to draw the Blend in. Rectangle rectangle1 = new Rectangle(10, 10, 120, 100); // Create a new LinearGradientBrush using the rectangle, // green and blue. and 90-degree angle. LinearGradientBrush brush1 = new LinearGradientBrush(rectangle1, Color.LightGreen, Color.Blue, 90, true); // Set the Blend property on the brush to the custom blend. brush1.Blend = blend1; // Fill in an ellipse with the brush. e.Graphics.FillEllipse(brush1, rectangle1); // Dispose of the custom brush. brush1.Dispose(); }
private: void DemonstrateBlend( PaintEventArgs^ e ) { Blend^ blend1 = gcnew Blend( 9 ); // Set the values in the Factors array to be all green, // go to all blue, and then go back to green. array<Single>^temp0 = {0.0F,0.2F,0.5F,0.7F,1.0F,0.7F,0.5F,0.2F,0.0F}; blend1->Factors = temp0; // Set the positions. array<Single>^temp1 = {0.0F,0.1F,0.3F,0.4F,0.5F,0.6F,0.7F,0.8F,1.0F}; blend1->Positions = temp1; // Declare a rectangle to draw the Blend in. Rectangle rectangle1 = Rectangle(10,10,120,100); // Create a new LinearGradientBrush using the rectangle, // green and blue. and 90-degree angle. LinearGradientBrush^ brush1 = gcnew LinearGradientBrush( rectangle1,Color::LightGreen,Color::Blue,90,true ); // Set the Blend property on the brush to the custom blend. brush1->Blend = blend1; // Fill in an ellipse with the brush. e->Graphics->FillEllipse( brush1, rectangle1 ); // Dispose of the custom brush. delete brush1; }
private void DemonstrateBlend(PaintEventArgs e) { Blend blend1 = new Blend(9); // Set the values in the Factors array to be all green, // go to all blue, and then go back to green. blend1.set_Factors(new float[] { 0.0F, 0.2F, 0.5F, 0.7F, 1.0F, 0.7F, 0.5F, 0.2F, 0.0F }); // Set the positions. blend1.set_Positions(new float[] { 0.0F, 0.1F, 0.3F, 0.4F, 0.5F, 0.6F, 0.7F, 0.8F, 1.0F }); // Declare a rectangle to draw the Blend in. Rectangle rectangle1 = new Rectangle(10, 10, 120, 100); // Create a new LinearGradientBrush using the rectangle, // green and blue. and 90-degree angle. LinearGradientBrush brush1 = new LinearGradientBrush(rectangle1 , Color.get_LightGreen(), Color.get_Blue(), 90, true); // Set the Blend property on the brush to the custom blend. brush1.set_Blend(blend1); // Fill in an ellipse with the brush. e.get_Graphics().FillEllipse(brush1, rectangle1); // Dispose of the custom brush. brush1.Dispose(); } //DemonstrateBlend

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Blend.Positions プロパティのページへのリンク