PathGradientBrush.ScaleTransform Metodo

Definizione

Modifica le proporzioni della trasformazione geometrica locale in base ai valori specificati. Questo metodo antepone la matrice per la modifica delle proporzioni alla trasformazione.

Overload

ScaleTransform(Single, Single)

Modifica le proporzioni della trasformazione geometrica locale in base ai valori specificati. Questo metodo antepone la matrice per la modifica delle proporzioni alla trasformazione.

ScaleTransform(Single, Single, MatrixOrder)

Modifica le proporzioni della trasformazione geometrica locale in base ai valori specificati nell'ordine indicato.

ScaleTransform(Single, Single)

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

Modifica le proporzioni della trasformazione geometrica locale in base ai valori specificati. Questo metodo antepone la matrice per la modifica delle proporzioni alla trasformazione.

public:
 void ScaleTransform(float sx, float sy);
public void ScaleTransform (float sx, float sy);
member this.ScaleTransform : single * single -> unit
Public Sub ScaleTransform (sx As Single, sy As Single)

Parametri

sx
Single

Fattore di modifica delle proporzioni della trasformazione nella direzione dell'asse x.

sy
Single

Fattore di modifica delle proporzioni della trasformazione nella direzione dell'asse y.

Esempio

Per un esempio, vedere ScaleTransform.

Si applica a

ScaleTransform(Single, Single, MatrixOrder)

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

Modifica le proporzioni della trasformazione geometrica locale in base ai valori specificati nell'ordine indicato.

public:
 void ScaleTransform(float sx, float sy, System::Drawing::Drawing2D::MatrixOrder order);
public void ScaleTransform (float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order);
member this.ScaleTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub ScaleTransform (sx As Single, sy As Single, order As MatrixOrder)

Parametri

sx
Single

Fattore di modifica delle proporzioni della trasformazione nella direzione dell'asse x.

sy
Single

Fattore di modifica delle proporzioni della trasformazione nella direzione dell'asse y.

order
MatrixOrder

Oggetto MatrixOrder che specifica se accodare o anteporre la matrice di ridimensionamento.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Codice

  • 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 di scala.

  • Applica la trasformazione di scala al pennello usando il ScaleTransform 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 tradotto sullo schermo.

Si noti che il rettangolo inferiore è due volte più lungo dell'asse x, come è quello disegnato prima della traduzione.

public:
   void ScaleTransformExample( 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 transformation.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );

      // Scale by a factor of 2 in the x-axis by applying the scale
      // transform to the brush.
      myPGBrush->ScaleTransform( 2, 1, MatrixOrder::Append );

      // Move the brush down by 100 by Applying the translate
      // transform to the brush.
      myPGBrush->TranslateTransform(  -100, 100, MatrixOrder::Append );

      // Draw the brush to the screen again after applying the
      // transforms.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
   }
public void ScaleTransformExample(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 transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
             
    // Scale by a factor of 2 in the x-axis by applying the scale
    // transform to the brush.
    myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append);
             
    // Move the brush down by 100 by Applying the translate
    // transform to the brush.
    myPGBrush.TranslateTransform(-100, 100, MatrixOrder.Append);
             
    // Draw the brush to the screen again after applying the
    // transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub ScaleTransformExample(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 transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)

    ' Scale by a factor of 2 in the x-axis by applying the scale
    ' transform to the brush.
    myPGBrush.ScaleTransform(2, 1, MatrixOrder.Append)

    ' Move the brush down by 100 by Applying the translate
    ' transform to the brush.
    myPGBrush.TranslateTransform(-100, 100, MatrixOrder.Append)

    ' Draw the brush to the screen again after applying the
    ' transforms.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub

Si applica a