PathGradientBrush.SetBlendTriangularShape Metoda

Definicja

Tworzy gradient z kolorem środkowym i liniowym spadkiem do jednego otaczającego koloru.

Przeciążenia

SetBlendTriangularShape(Single)

Tworzy gradient z kolorem środkowym i liniowym spadkiem do jednego otaczającego koloru.

SetBlendTriangularShape(Single, Single)

Tworzy gradient z kolorem środkowym i spadkiem liniowym do każdego otaczającego koloru.

SetBlendTriangularShape(Single)

Źródło:
PathGradientBrush.cs
Źródło:
PathGradientBrush.cs
Źródło:
PathGradientBrush.cs

Tworzy gradient z kolorem środkowym i liniowym spadkiem do jednego otaczającego koloru.

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

Parametry

focus
Single

Wartość z zakresu od 0 do 1, która określa, gdzie wzdłuż dowolnego promienia od środka ścieżki do granicy ścieżki, kolor środkowy będzie na najwyższym natężeniu. Wartość 1 (wartość domyślna) umieszcza najwyższą intensywność w środku ścieżki.

Przykłady

Aby zapoznać się z przykładem, zobacz SetBlendTriangularShape.

Uwagi

Jeśli tablica SurroundColors zawiera więcej niż jeden kolor, pierwszy kolor tablicy jest używany dla koloru końcowego. Kolory określone w tej tablicy są używane do punktów dyskretnych na ścieżce granic pędzla.

Dotyczy

SetBlendTriangularShape(Single, Single)

Źródło:
PathGradientBrush.cs
Źródło:
PathGradientBrush.cs
Źródło:
PathGradientBrush.cs

Tworzy gradient z kolorem środkowym i spadkiem liniowym do każdego otaczającego koloru.

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)

Parametry

focus
Single

Wartość z zakresu od 0 do 1, która określa, gdzie wzdłuż dowolnego promienia od środka ścieżki do granicy ścieżki, kolor środkowy będzie na najwyższym natężeniu. Wartość 1 (wartość domyślna) umieszcza najwyższą intensywność w środku ścieżki.

scale
Single

Wartość z zakresu od 0 do 1, która określa maksymalną intensywność koloru środka, który jest mieszany z kolorem granicy. Wartość 1 powoduje najwyższą możliwą intensywność koloru środka i jest to wartość domyślna.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseOnPaint obiektu zdarzenia . Kod wykonuje następujące akcje:

  • Tworzy ścieżkę graficzną i dodaje do niego prostokąt.

  • Tworzy element PathGradientBrush z punktów ścieżki (w tym przykładzie punkty tworzą prostokąt, ale może to być najbardziej dowolny kształt).

  • Ustawia kolor środkowy na czerwony i otaczający kolor na niebieski.

  • Rysuje ekran PathGradientBrush przed zastosowaniem przekształcenia blend.

  • Stosuje transformację mieszanki do pędzla przy użyciu jego SetBlendTriangularShape metody.

  • Wywołuje metodę TranslateTransform , aby przenieść prostokąt pędzla, tak aby nie nakładał się na nią wcześniej.

  • Rysuje prostokąt przekształconego pędzla narysowany na ekranie.

Zwróć uwagę, że maksymalny kolor środkowy (czerwony) znajduje się w połowie drogi od środka ścieżki do granicy ścieżki.

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

Uwagi

Jeśli tablica SurroundColors zawiera więcej niż jeden kolor, pierwszy kolor tablicy jest używany dla koloru końcowego. Kolory określone w tej tablicy są kolorami używanymi dla dyskretnych punktów na ścieżce granic pędzla.

Domyślnie po przejściu z granicy gradientu ścieżki do punktu środkowego kolor zmienia się stopniowo z koloru granicy na kolor środkowy. Możesz dostosować pozycjonowanie i mieszanie kolorów granic i środkowych, wywołując tę metodę.

Dotyczy