PathGradientBrush.SetBlendTriangularShape Metodo

Definizione

Crea una sfumatura con un colore centrale e un'interruzione lineare su un colore circostante.

Overload

SetBlendTriangularShape(Single)

Crea una sfumatura con un colore centrale e un'interruzione lineare su un colore circostante.

SetBlendTriangularShape(Single, Single)

Crea una sfumatura con un colore centrale e un'interruzione lineare su ciascun colore circostante.

SetBlendTriangularShape(Single)

Origine:
PathGradientBrush.cs
Origine:
PathGradientBrush.cs
Origine:
PathGradientBrush.cs

Crea una sfumatura con un colore centrale e un'interruzione lineare su un colore circostante.

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

Parametri

focus
Single

Valore compreso tra 0 e 1 che specifica il punto in cui, lungo qualsiasi radiale dal centro al limite del percorso, si troverà la massima intensità del colore centrale. Il valore 1 (valore predefinito) posiziona la massima intensità al centro del percorso.

Esempio

Per un esempio, vedere SetBlendTriangularShape.

Commenti

Se nella matrice sono presenti più colori, il primo colore della SurroundColors matrice viene usato per il colore finale. I colori specificati in questa matrice vengono usati per punti discreti sul percorso limite del pennello.

Si applica a

SetBlendTriangularShape(Single, Single)

Origine:
PathGradientBrush.cs
Origine:
PathGradientBrush.cs
Origine:
PathGradientBrush.cs

Crea una sfumatura con un colore centrale e un'interruzione lineare su ciascun colore circostante.

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)

Parametri

focus
Single

Valore compreso tra 0 e 1 che specifica il punto in cui, lungo qualsiasi radiale dal centro al limite del percorso, si troverà la massima intensità del colore centrale. Il valore 1 (valore predefinito) posiziona la massima intensità al centro del percorso.

scale
Single

Valore compreso tra 0 e 1 che specifica l'intensità massima del colore centrale, sfumato con il colore del limite. Il valore 1 indica la massima intensità possibile del colore centrale e rappresenta l'impostazione predefinita.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Il codice esegue le azioni seguenti:

  • Crea un percorso grafico e aggiunge un rettangolo.

  • Crea un PathGradientBrush oggetto dai punti del percorso (in questo esempio, i punti formano un rettangolo, ma potrebbero essere la maggior parte di qualsiasi forma).

  • Imposta il colore centrale su rosso e sul colore circostante su blu.

  • Disegna l'oggetto PathGradientBrush sullo schermo prima di applicare la trasformazione blend.

  • Applica la trasformazione blend al pennello usando il SetBlendTriangularShape relativo metodo.

  • Chiama il metodo per spostare il TranslateTransform rettangolo del pennello in modo che non sovrappone quello disegnato in precedenza allo schermo.

  • Disegna il rettangolo di pennello trasformato viene disegnato sullo schermo.

Si noti che il colore centrale massimo (rosso) si trova metà dal centro del percorso al limite del percorso.

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

Commenti

Se nella matrice sono presenti più colori, il primo colore della SurroundColors matrice viene usato per il colore finale. I colori specificati in questa matrice sono colori usati per punti discreti sul percorso limite del pennello.

Per impostazione predefinita, quando si passa dal limite di un percorso sfumatura al punto centrale, il colore cambia gradualmente dal colore limite al colore centrale. È possibile personalizzare la posizione e la fusione dei colori del limite e del centro chiamando questo metodo.

Si applica a