Share via


PathGradientBrush.SetBlendTriangularShape Methode

Definition

Erstellt einen Farbverlauf mit einer Farbe in der Mitte und einem linearen Übergang in eine Umgebungsfarbe.

Überlädt

SetBlendTriangularShape(Single)

Erstellt einen Farbverlauf mit einer Farbe in der Mitte und einem linearen Übergang in eine Umgebungsfarbe.

SetBlendTriangularShape(Single, Single)

Erstellt einen Farbverlauf mit einer Farbe in der Mitte und einem linearen Übergang in jede Umgebungsfarbe.

SetBlendTriangularShape(Single)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Erstellt einen Farbverlauf mit einer Farbe in der Mitte und einem linearen Übergang in eine Umgebungsfarbe.

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

Parameter

focus
Single

Ein Wert von 0 (null) bis 1, der angibt, wo die Mittelpunktfarbe entlang einer beliebigen Radiallinie von der Mitte des Pfads bis zu dessen Rand über die höchste Intensität verfügt. Der Wert 1 (Standardwert) positioniert die höchste Intensität in die Mitte des Pfads.

Beispiele

Ein Beispiel finden Sie unter SetBlendTriangularShape.

Hinweise

Wenn mehr als eine Farbe im SurroundColors Array vorhanden ist, wird die erste Farbe im Array für die Endfarbe verwendet. Die in diesem Array angegebenen Farben werden für diskrete Punkte im Begrenzungspfad des Pinsels verwendet.

Gilt für:

SetBlendTriangularShape(Single, Single)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Erstellt einen Farbverlauf mit einer Farbe in der Mitte und einem linearen Übergang in jede Umgebungsfarbe.

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)

Parameter

focus
Single

Ein Wert von 0 (null) bis 1, der angibt, wo die Mittelpunktfarbe entlang einer beliebigen Radiallinie von der Mitte des Pfads bis zu dessen Rand über die höchste Intensität verfügt. Der Wert 1 (Standardwert) positioniert die höchste Intensität in die Mitte des Pfads.

scale
Single

Ein Wert von 0 (null) bis 1, der die maximale Intensität der in die Randfarbe übergehenden Mittelpunktfarbe angibt. Beim Standardwert 1 hat die Mittelpunktfarbe die größtmögliche Intensität.

Beispiele

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgseein OnPaint Ereignisobjekt. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen Grafikpfad und fügt ein Rechteck hinzu.

  • Erstellt ein PathGradientBrush aus den Pfadpunkten (in diesem Beispiel bilden die Punkte ein Rechteck, aber es kann sich um die meisten Formen handeln).

  • Legt die Mittlere Farbe auf Rot und die umgebende Farbe auf Blau fest.

  • Zeichnet die PathGradientBrush vor dem Anwenden der Blendtransformation auf den Bildschirm.

  • Wendet die Blendtransformation mithilfe der zugehörigen SetBlendTriangularShape Methode auf den Pinsel an.

  • Ruft die TranslateTransform -Methode auf, um das Pinselrechteck so zu verschieben, dass das zuvor auf den Bildschirm gezeichnete Rechteck nicht überlagert wird.

  • Zeichnet das transformierte Pinselrechteck wird auf den Bildschirm gezeichnet.

Beachten Sie, dass sich die maximale Mittlere Farbe (rot) auf halbem Weg von der Mitte des Pfads bis zur Pfadgrenze befindet.

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

Hinweise

Wenn mehr als eine Farbe im SurroundColors Array vorhanden ist, wird die erste Farbe im Array für die Endfarbe verwendet. Die in diesem Array angegebenen Farben sind Farben, die für diskrete Punkte im Begrenzungspfad des Pinsels verwendet werden.

Wenn Sie von der Begrenzung eines Pfadverlaufs zum Mittelpunkt wechseln, ändert sich die Farbe standardmäßig schrittweise von der Begrenzungsfarbe zur mittleren Farbe. Sie können die Positionierung und Das Mischen der Begrenzungs- und Mittelfarben anpassen, indem Sie diese Methode aufrufen.

Gilt für: