Compartir vía


PathGradientBrush.SetBlendTriangularShape Método

Definición

Crea un degradado con un color central y una caída lineal a un color circundante.

Sobrecargas

SetBlendTriangularShape(Single)

Crea un degradado con un color central y una caída lineal a un color circundante.

SetBlendTriangularShape(Single, Single)

Crea un degradado con un color central y una caída lineal a cada color circundante.

SetBlendTriangularShape(Single)

Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs

Crea un degradado con un color central y una caída lineal a un color circundante.

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

Valor comprendido entre 0 y 1 que especifica dónde, a lo largo de cualquier radial desde el centro de la ruta de acceso hasta el límite de la ruta, el color central estará en su máxima intensidad. Un valor de 1 (valor predeterminado) coloca la intensidad más alta en el centro del trazado.

Ejemplos

Para obtener un ejemplo, consulte SetBlendTriangularShape.

Comentarios

Si hay más de un color en la matriz de SurroundColors, se usa el primer color de la matriz para el color final. Los colores especificados en esta matriz se usan para puntos discretos en la ruta de acceso de límite del pincel.

Se aplica a

SetBlendTriangularShape(Single, Single)

Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs

Crea un degradado con un color central y una caída lineal a cada color circundante.

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

Valor comprendido entre 0 y 1 que especifica dónde, a lo largo de cualquier radial desde el centro de la ruta de acceso hasta el límite de la ruta, el color central estará en su máxima intensidad. Un valor de 1 (valor predeterminado) coloca la intensidad más alta en el centro del trazado.

scale
Single

Valor comprendido entre 0 y 1 que especifica la intensidad máxima del color central que se mezcla con el color de límite. Un valor de 1 provoca la mayor intensidad posible del color central y es el valor predeterminado.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un objeto de evento OnPaint. El código realiza las siguientes acciones:

  • Crea una ruta de acceso de gráficos y agrega un rectángulo a él.

  • Crea un PathGradientBrush a partir de los puntos de ruta de acceso (en este ejemplo, los puntos forman un rectángulo, pero podría ser la mayoría de las formas).

  • Establece el color central en rojo y el color circundante en azul.

  • Dibuja el PathGradientBrush en la pantalla antes de aplicar la transformación de mezcla.

  • Aplica la transformación de mezcla al pincel mediante su método SetBlendTriangularShape.

  • Llama al método TranslateTransform para mover el rectángulo de pincel de forma que no superponga el dibujado a la pantalla anteriormente.

  • Dibuja el rectángulo de pincel transformado que se dibuja en la pantalla.

Observe que el color central máximo (rojo) se encuentra a mitad del centro de la ruta de acceso al límite de la ruta de acceso.

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

Comentarios

Si hay más de un color en la matriz de SurroundColors, se usa el primer color de la matriz para el color final. Los colores especificados en esta matriz son colores usados para puntos discretos en la ruta de acceso de límite del pincel.

De forma predeterminada, a medida que se mueve del límite de un degradado de ruta al punto central, el color cambia gradualmente del color del límite al color central. Puede personalizar el posicionamiento y la combinación de los colores de límite y centro llamando a este método.

Se aplica a