Sdílet prostřednictvím


PathGradientBrush.SetBlendTriangularShape Metoda

Definice

Vytvoří přechod se středovou barvou a lineárním přechodem na jednu okolní barvu.

Přetížení

SetBlendTriangularShape(Single)

Vytvoří přechod se středovou barvou a lineárním přechodem na jednu okolní barvu.

SetBlendTriangularShape(Single, Single)

Vytvoří přechod se středovou barvou a lineárním přechodem na každou okolní barvu.

SetBlendTriangularShape(Single)

Zdroj:
PathGradientBrush.cs
Zdroj:
PathGradientBrush.cs
Zdroj:
PathGradientBrush.cs

Vytvoří přechod se středovou barvou a lineárním přechodem na jednu okolní barvu.

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

Parametry

focus
Single

Hodnota od 0 do 1, která určuje, kde podél libovolné radiály od středu cesty k hranici cesty bude středová barva v nejvyšší intenzitě. Hodnota 1 (výchozí) umístí nejvyšší intenzitu do středu cesty.

Příklady

Příklad najdete v tématu SetBlendTriangularShape.

Poznámky

Pokud je v matici SurroundColors více než jedna barva, použije se pro koncovou barvu první barva v matici. Barvy zadané v této matici se používají pro samostatné body na cestě hranice štětce.

Platí pro

SetBlendTriangularShape(Single, Single)

Zdroj:
PathGradientBrush.cs
Zdroj:
PathGradientBrush.cs
Zdroj:
PathGradientBrush.cs

Vytvoří přechod se středovou barvou a lineárním přechodem na každou okolní barvu.

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

Hodnota od 0 do 1, která určuje, kde podél libovolné radiály od středu cesty k hranici cesty bude středová barva v nejvyšší intenzitě. Hodnota 1 (výchozí) umístí nejvyšší intenzitu do středu cesty.

scale
Single

Hodnota od 0 do 1, která určuje maximální intenzitu středové barvy, která se prolíná s barvou ohraničení. Hodnota 1 způsobuje nejvyšší možnou intenzitu středové barvy a je to výchozí hodnota.

Příklady

Následující příklad kódu je navržený pro použití s model Windows Forms a vyžaduje PaintEventArgseOnPaint objekt události. Kód provede následující akce:

  • Vytvoří cestu grafiky a přidá do ní obdélník.

  • PathGradientBrush Vytvoří z bodů cesty (v tomto příkladu body tvoří obdélník, ale může to být většina libovolného obrazce).

  • Nastaví prostřední barvu na červenou a barvu okolí na modrou.

  • Před použitím transformace blendu PathGradientBrush nakreslí objekt na obrazovku.

  • Použije transformaci blendu na štětec pomocí jeho SetBlendTriangularShape metody.

  • Zavolá metodu TranslateTransform pro přesunutí obdélníku štětce tak, aby nepřekryl obdélník nakreslený na obrazovku dříve.

  • Nakreslí na obrazovku obdélník transformovaného štětce.

Všimněte si, že maximální barva na střed (červená) je umístěna v polovině od středu cesty k hranici cesty.

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

Poznámky

Pokud je v matici SurroundColors více než jedna barva, použije se pro koncovou barvu první barva v matici. Barvy zadané v této matici jsou barvy používané pro samostatné body v cestě hranice štětce.

Ve výchozím nastavení se při přechodu z hranice přechodu cesty do středového bodu barva postupně mění z barvy ohraničení na barvu středu. Můžete přizpůsobit umístění a prolnutí okrajové a středové barvy voláním této metody.

Platí pro