PathGradientBrush.ScaleTransform Méthode

Définition

Effectue une mise à l'échelle de la transformation géométrique locale selon les valeurs spécifiées. Cette méthode ajoute la matrice de mise à l'échelle avant la transformation.

Surcharges

ScaleTransform(Single, Single)

Effectue une mise à l'échelle de la transformation géométrique locale selon les valeurs spécifiées. Cette méthode ajoute la matrice de mise à l'échelle avant la transformation.

ScaleTransform(Single, Single, MatrixOrder)

Effectue une mise à l'échelle de la transformation géométrique locale conformément aux valeurs et à l'ordre spécifiés.

ScaleTransform(Single, Single)

Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs

Effectue une mise à l'échelle de la transformation géométrique locale selon les valeurs spécifiées. Cette méthode ajoute la matrice de mise à l'échelle avant la transformation.

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)

Paramètres

sx
Single

Facteur d'échelle de la transformation sur l'axe x.

sy
Single

Facteur d'échelle de la transformation sur l'axe y.

Exemples

Pour obtenir un exemple, consultez ScaleTransform.

S’applique à

ScaleTransform(Single, Single, MatrixOrder)

Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs

Effectue une mise à l'échelle de la transformation géométrique locale conformément aux valeurs et à l'ordre spécifiés.

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)

Paramètres

sx
Single

Facteur d'échelle de la transformation sur l'axe x.

sy
Single

Facteur d'échelle de la transformation sur l'axe y.

order
MatrixOrder

MatrixOrder qui spécifie si la matrice de mise à l'échelle doit être ajoutée avant ou après.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, un objet d’événementOnPaint. Code

  • Crée un chemin d’accès graphique et y ajoute un rectangle.

  • Crée un PathGradientBrush à partir des points de chemin d’accès (dans cet exemple, les points forment un rectangle, mais il peut s’agir de n’importe quelle forme).

  • Définit la couleur centrale sur rouge et la couleur environnante sur le bleu.

  • Dessine sur PathGradientBrush l’écran avant d’appliquer la transformation d’échelle.

  • Applique la transformation d’échelle au pinceau à l’aide de sa ScaleTransform méthode .

  • Appelle la TranslateTransform méthode pour déplacer le rectangle de pinceau de sorte qu’il ne superpose pas celui dessiné à l’écran précédemment.

  • Dessine le rectangle de pinceau traduit à l’écran.

Notez que le rectangle inférieur est deux fois plus long dans l’axe X que celui dessiné avant la traduction.

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

S’applique à