Freigeben über


PathGradientBrush.SetBlendTriangularShape Methode

Definition

Erstellt einen Farbverlauf mit einer mittleren Farbe und einem linearen Falloff zu einer umgebenden Farbe.

Überlädt

SetBlendTriangularShape(Single)

Erstellt einen Farbverlauf mit einer mittleren Farbe und einem linearen Falloff zu einer umgebenden Farbe.

SetBlendTriangularShape(Single, Single)

Erstellt einen Farbverlauf mit einer mittleren Farbe und einem linearen Falloff zu jeder umgebenden Farbe.

SetBlendTriangularShape(Single)

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

Erstellt einen Farbverlauf mit einer mittleren Farbe und einem linearen Falloff zu einer umgebenden Farbe.

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 bis 1, der angibt, wo entlang eines radialen Bereichs von der Mitte des Pfads zur Grenze des Pfads die mittlere Farbe angibt. Ein Wert von 1 (Standardeinstellung) platziert die höchste Intensität in der Mitte des Pfads.

Beispiele

Ein Beispiel finden Sie unter SetBlendTriangularShape.

Hinweise

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

Gilt für:

SetBlendTriangularShape(Single, Single)

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

Erstellt einen Farbverlauf mit einer mittleren Farbe und einem linearen Falloff zu jeder umgebenden Farbe.

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 bis 1, der angibt, wo entlang eines radialen Bereichs von der Mitte des Pfads zur Grenze des Pfads die mittlere Farbe angibt. Ein Wert von 1 (Standardeinstellung) platziert die höchste Intensität in der Mitte des Pfads.

scale
Single

Ein Wert von 0 bis 1, der die maximale Intensität der Mittelfarbe angibt, die mit der Begrenzungsfarbe vermischt wird. Ein Wert von 1 verursacht die höchste mögliche Intensität der Mittelfarbe und ist der Standardwert.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, ein OnPaint-Ereignisobjekt. Der Code führt die folgenden Aktionen aus:

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

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

  • Legt die Mittelfarbe 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 SetBlendTriangularShape-Methode auf den Pinsel an.

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

  • Zeichnet das transformierte Pinselrechteck auf dem Bildschirm.

Beachten Sie, dass sich die maximale Mittelfarbe (Rot) halb vom Mittelpunkt des Pfads 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 im SurroundColors Array mehr als eine Farbe 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 auf dem Begrenzungspfad des Pinsels verwendet werden.

Wenn Sie von der Grenze eines Pfadverlaufs zum Mittelpunkt wechseln, ändert sich die Farbe standardmäßig schrittweise von der Begrenzungsfarbe in die Mittelfarbe. Sie können die Positionierung und Vermischung der Begrenzungs- und Mittelfarben anpassen, indem Sie diese Methode aufrufen.

Gilt für: