Partage via


PathGradientBrush.SetBlendTriangularShape Méthode

Définition

Crée un dégradé avec une couleur centrale et une chute linéaire à une couleur environnante.

Surcharges

SetBlendTriangularShape(Single)

Crée un dégradé avec une couleur centrale et une chute linéaire à une couleur environnante.

SetBlendTriangularShape(Single, Single)

Crée un dégradé avec une couleur centrale et une chute linéaire à chaque couleur environnante.

SetBlendTriangularShape(Single)

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

Crée un dégradé avec une couleur centrale et une chute linéaire à une couleur environnante.

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

Paramètres

focus
Single

Valeur comprise entre 0 et 1 qui spécifie où, le long de n’importe quel radial du centre du chemin vers la limite du chemin, la couleur centrale est à son intensité la plus élevée. La valeur 1 (valeur par défaut) place l’intensité la plus élevée au centre du chemin.

Exemples

Pour obtenir un exemple, consultez SetBlendTriangularShape.

Remarques

S’il existe plusieurs couleurs dans le tableau SurroundColors, la première couleur du tableau est utilisée pour la couleur de fin. Les couleurs spécifiées dans ce tableau sont utilisées pour les points discrets sur le chemin de limite du pinceau.

S’applique à

SetBlendTriangularShape(Single, Single)

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

Crée un dégradé avec une couleur centrale et une chute linéaire à chaque couleur environnante.

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)

Paramètres

focus
Single

Valeur comprise entre 0 et 1 qui spécifie où, le long de n’importe quel radial du centre du chemin vers la limite du chemin, la couleur centrale est à son intensité la plus élevée. La valeur 1 (valeur par défaut) place l’intensité la plus élevée au centre du chemin.

scale
Single

Valeur comprise entre 0 et 1 qui spécifie l’intensité maximale de la couleur centrale qui est fusionnée avec la couleur de limite. La valeur 1 entraîne la plus forte intensité possible de la couleur centrale, et il s’agit de la valeur par défaut.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, un objet d’événement OnPaint. Le code effectue les actions suivantes :

  • Crée un chemin d’accès graphique et ajoute un rectangle à celui-ci.

  • Crée un PathGradientBrush à partir des points de chemin d’accès (dans cet exemple, les points forment un rectangle, mais il peut s’agir de la plupart des formes).

  • Définit la couleur centrale sur rouge et la couleur environnante sur bleu.

  • Dessine le PathGradientBrush à l’écran avant d’appliquer la transformation de fusion.

  • Applique la transformation de fusion au pinceau à l’aide de sa méthode de SetBlendTriangularShape.

  • Appelle la méthode TranslateTransform pour déplacer le rectangle de pinceau de sorte qu’il ne superpose pas celui dessiné à l’écran précédemment.

  • Dessine le rectangle de pinceau transformé à l’écran.

Notez que la couleur centrale maximale (rouge) est située à mi-chemin du centre du chemin d’accès à la limite du chemin.

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

Remarques

S’il existe plusieurs couleurs dans le tableau SurroundColors, la première couleur du tableau est utilisée pour la couleur de fin. Les couleurs spécifiées dans ce tableau sont des couleurs utilisées pour les points discrets sur le chemin de limite du pinceau.

Par défaut, lorsque vous passez de la limite d’un dégradé de chemin vers le point central, la couleur passe progressivement de la couleur de limite à la couleur centrale. Vous pouvez personnaliser le positionnement et le mélange des couleurs de limite et de centre en appelant cette méthode.

S’applique à