PathGradientBrush.SetBlendTriangularShape Méthode

Définition

Crée un dégradé comportant une couleur centrale et une atténuation linéaire vers une couleur environnante.

Surcharges

SetBlendTriangularShape(Single)

Crée un dégradé comportant une couleur centrale et une atténuation linéaire vers une couleur environnante.

SetBlendTriangularShape(Single, Single)

Crée un dégradé comportant une couleur centrale et une atténuation linéaire vers chacune des couleurs environnantes.

SetBlendTriangularShape(Single)

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

Crée un dégradé comportant une couleur centrale et une atténuation linéaire vers 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 de 0 à 1 qui spécifie la position à laquelle la couleur centrale sera la plus intense, le long de n'importe quelle ligne radiale allant du centre vers le bord du tracé. La valeur 1 (valeur par défaut) définit l'intensité maximale au centre du tracé.

Exemples

Pour obtenir un exemple, consultez SetBlendTriangularShape.

Remarques

S’il existe plusieurs couleurs dans le SurroundColors tableau, 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

Crée un dégradé comportant une couleur centrale et une atténuation linéaire vers chacune des couleurs environnantes.

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 de 0 à 1 qui spécifie la position à laquelle la couleur centrale sera la plus intense, le long de n'importe quelle ligne radiale allant du centre vers le bord du tracé. La valeur 1 (valeur par défaut) définit l'intensité maximale au centre du tracé.

scale
Single

Valeur de 0 à 1 qui spécifie l'intensité maximale de la couleur centrale qui est mélangée avec la couleur du bord. Une valeur de 1 correspond à l'intensité maximale de la couleur centrale. 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énementOnPaint. Le code effectue les actions suivantes :

  • Crée un chemin d’accès graphique et y ajoute un rectangle.

  • 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 n’importe quelle forme).

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

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

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

  • Appelle la TranslateTransform méthode pour déplacer le rectangle de pinceau de manière à ne pas superposer celui dessiné à l’écran précédemment.

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

Notez que la couleur centrale maximale (rouge) se trouve à mi-chemin du centre du chemin d’accès à la limite du chemin d’accès.

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 SurroundColors tableau, 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 au point central, la couleur passe progressivement de la couleur de limite à la couleur centrale. Vous pouvez personnaliser le positionnement et la fusion de la limite et des couleurs du centre en appelant cette méthode.

S’applique à