Blend.Positions Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u een matrix van mengposities voor de kleurovergang op of stelt u deze in.
public:
property cli::array <float> ^ Positions { cli::array <float> ^ get(); void set(cli::array <float> ^ value); };
public float[] Positions { get; set; }
member this.Positions : single[] with get, set
Public Property Positions As Single()
Waarde van eigenschap
Een matrix met mengposities die de percentages van afstand langs de kleurovergangslijn opgeven.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de Blend klasse gebruikt door de Factors en Positions eigenschappen in te stellen. Dit voorbeeld is ontworpen voor gebruik met Windows Forms. Plak de code in een formulier waarmee de System.Drawing.Drawing2D naamruimte wordt geïmporteerd. De gebeurtenis van Paint het formulier afhandelen en de DemonstrateBlend methode aanroepen, waarbij deze wordt doorgegeven e als PaintEventArgs.
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.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 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
Opmerkingen
De elementen van deze matrix geven percentages van afstand langs de kleurovergangslijn op. Een elementwaarde van 0,2f geeft bijvoorbeeld aan dat dit punt 20 procent van de totale afstand van het beginpunt is. De elementen in deze matrix worden vertegenwoordigd door floatwaarden tussen 0,0f en 1,0f. Het eerste element van de matrix moet 0,0f zijn en het laatste element moet 1,0f zijn.