Condividi tramite


PathGradientBrush.ScaleTransform Metodo

Definizione

Ridimensiona la trasformazione geometrica locale in base agli importi specificati. Questo metodo antepone la matrice di ridimensionamento alla trasformazione.

Overload

ScaleTransform(Single, Single)

Ridimensiona la trasformazione geometrica locale in base agli importi specificati. Questo metodo antepone la matrice di ridimensionamento alla trasformazione.

ScaleTransform(Single, Single, MatrixOrder)

Ridimensiona la trasformazione geometrica locale in base agli importi specificati nell'ordine specificato.

ScaleTransform(Single, Single)

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

Ridimensiona la trasformazione geometrica locale in base agli importi specificati. Questo metodo antepone la matrice di ridimensionamento 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 scala della trasformazione nella direzione dell'asse x.

sy
Single

Fattore di scala 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
Origine:
PathGradientBrush.cs
Origine:
PathGradientBrush.cs

Ridimensiona la trasformazione geometrica locale in base agli importi specificati nell'ordine specificato.

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 scala della trasformazione nella direzione dell'asse x.

sy
Single

Fattore di scala della trasformazione nella direzione dell'asse y.

order
MatrixOrder

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

Esempio

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

  • Crea un percorso grafico e aggiunge un rettangolo.

  • Crea un PathGradientBrush 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 sul rosso e sul colore circostante su blu.

  • Disegna il PathGradientBrush sullo schermo prima di applicare la trasformazione della scala.

  • Applica la trasformazione di scala al pennello usando il relativo metodo ScaleTransform.

  • Chiama il metodo TranslateTransform per spostare il rettangolo del pennello in modo che non sovrappone quello disegnato in precedenza allo schermo.

  • Disegna il rettangolo del pennello convertito sullo schermo.

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

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