Share via


PathGradientBrush.SetBlendTriangularShape Método

Definição

Cria um gradiente com uma cor central e uma queda linear para uma cor ao redor.

Sobrecargas

SetBlendTriangularShape(Single)

Cria um gradiente com uma cor central e uma queda linear para uma cor ao redor.

SetBlendTriangularShape(Single, Single)

Cria um gradiente com uma cor central e uma queda linear para cada cor ao redor.

SetBlendTriangularShape(Single)

Origem:
PathGradientBrush.cs
Origem:
PathGradientBrush.cs
Origem:
PathGradientBrush.cs

Cria um gradiente com uma cor central e uma queda linear para uma cor ao redor.

public:
 void SetBlendTriangularShape(float focus);
public void SetBlendTriangularShape (float focus);
member this.SetBlendTriangularShape : single -> unit
Public Sub SetBlendTriangularShape (focus As Single)

Parâmetros

focus
Single

Um valor entre 0 e 1 que especifica em que ponto, ao longo de qualquer radial do centro do caminho até o limite do caminho, a cor central estará em sua intensidade mais alta. Um valor de 1 (o padrão) coloca a intensidade mais alta no centro do caminho.

Exemplos

Para obter um exemplo, consulte SetBlendTriangularShape.

Comentários

Se houver mais de uma cor na SurroundColors matriz, a primeira cor na matriz será usada para a cor final. As cores especificadas nessa matriz são usadas para pontos discretos no caminho de limite do pincel.

Aplica-se a

SetBlendTriangularShape(Single, Single)

Origem:
PathGradientBrush.cs
Origem:
PathGradientBrush.cs
Origem:
PathGradientBrush.cs

Cria um gradiente com uma cor central e uma queda linear para cada cor ao redor.

public:
 void SetBlendTriangularShape(float focus, float scale);
public void SetBlendTriangularShape (float focus, float scale);
member this.SetBlendTriangularShape : single * single -> unit
Public Sub SetBlendTriangularShape (focus As Single, scale As Single)

Parâmetros

focus
Single

Um valor entre 0 e 1 que especifica em que ponto, ao longo de qualquer radial do centro do caminho até o limite do caminho, a cor central estará em sua intensidade mais alta. Um valor de 1 (o padrão) coloca a intensidade mais alta no centro do caminho.

scale
Single

Um valor entre 0 e 1 que especifica a intensidade máxima da cor central que é combinada à cor do limite. Um valor de 1 causa a intensidade mais alta possível da cor central e é o valor padrão.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, um OnPaint objeto de evento. O código executa as seguintes ações:

  • Cria um caminho gráfico e adiciona um retângulo a ele.

  • Cria um PathGradientBrush dos pontos de caminho (neste exemplo, os pontos formam um retângulo, mas pode ser a maioria de qualquer forma).

  • Define a cor central como vermelho e a cor ao redor como azul.

  • Desenha o PathGradientBrush na tela antes de aplicar a transformação de mesclagem.

  • Aplica a transformação de mesclagem ao pincel usando seu SetBlendTriangularShape método .

  • Chama o TranslateTransform método para mover o retângulo do pincel de modo que ele não sobreponha aquele desenhado para a tela anteriormente.

  • Desenha o retângulo de pincel transformado é desenhado para a tela.

Observe que a cor central máxima (vermelho) está localizada a meio caminho do centro do caminho até o limite do caminho.

public:
   void SetBlendTriangularShapeExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add a rectangle.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(100,20,100,50);
      myPath->AddRectangle( rect );

      // Get the path's array of points.
      array<PointF>^myPathPointArray = myPath->PathPoints;

      // Create a path gradient brush.
      PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );

      // Set the color span.
      myPGBrush->CenterColor = Color::Red;
      array<Color>^ mySurroundColor = {Color::Blue};
      myPGBrush->SurroundColors = mySurroundColor;

      // Draw the brush to the screen prior to the blend.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );

      // Set the Blend factors.
      myPGBrush->SetBlendTriangularShape( 0.5f, 1.0f );

      // Move the brush down by 100 by Applying the translate
      // transform to the brush.
      myPGBrush->TranslateTransform( 0, 100, MatrixOrder::Append );

      // Draw the brush to the screen again after applying the
      // transforms.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
   }
public void SetBlendTriangularShapeExample(PaintEventArgs e)
{
             
    // Create a graphics path and add a rectangle.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle rect = new Rectangle(100, 20, 100, 50);
    myPath.AddRectangle(rect);
             
    // Get the path's array of points.
    PointF[] myPathPointArray = myPath.PathPoints;
             
    // Create a path gradient brush.
    PathGradientBrush myPGBrush = new
        PathGradientBrush(myPathPointArray);
             
    // Set the color span.
    myPGBrush.CenterColor = Color.Red;
    Color[] mySurroundColor = {Color.Blue};
    myPGBrush.SurroundColors = mySurroundColor;
             
    // Draw the brush to the screen prior to the blend.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
             
    // Set the Blend factors.
    myPGBrush.SetBlendTriangularShape(0.5f, 1.0f);
             
    // Move the brush down by 100 by Applying the translate
    // transform to the brush.
    myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append);
             
    // Draw the brush to the screen again after applying the
    // transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub SetBlendTriangularShapeExample(ByVal e As PaintEventArgs)

    ' Create a graphics path and add a rectangle.
    Dim myPath As New GraphicsPath
    Dim rect As New Rectangle(100, 20, 100, 50)
    myPath.AddRectangle(rect)

    ' Get the path's array of points.
    Dim myPathPointArray As PointF() = myPath.PathPoints

    ' Create a path gradient brush.
    Dim myPGBrush As New PathGradientBrush(myPathPointArray)

    ' Set the color span.
    myPGBrush.CenterColor = Color.Red
    Dim mySurroundColor As Color() = {Color.Blue}
    myPGBrush.SurroundColors = mySurroundColor

    ' Draw the brush to the screen prior to blend.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)

    ' Set the Blend factors.
    myPGBrush.SetBlendTriangularShape(0.5F, 1.0F)

    ' Move the brush down by 100 by Applying the translate
    ' transform to the brush.
    myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append)

    ' Draw the brush to the screen again after applying the
    ' transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub

Comentários

Se houver mais de uma cor na SurroundColors matriz, a primeira cor na matriz será usada para a cor final. As cores especificadas nesta matriz são cores usadas para pontos discretos no caminho de limite do pincel.

Por padrão, à medida que você passa do limite de um gradiente de caminho para o ponto central, a cor muda gradualmente da cor do limite para a cor central. Você pode personalizar o posicionamento e a mesclagem das cores de limite e centro chamando esse método.

Aplica-se a