Partage via


PathGradientBrush.ScaleTransform Méthode

Définition

Met à l’échelle la transformation géométrique locale par les quantités spécifiées. Cette méthode précède la matrice de mise à l’échelle de la transformation.

Surcharges

ScaleTransform(Single, Single)

Met à l’échelle la transformation géométrique locale par les quantités spécifiées. Cette méthode précède la matrice de mise à l’échelle de la transformation.

ScaleTransform(Single, Single, MatrixOrder)

Met à l’échelle la transformation géométrique locale par les quantités spécifiées dans l’ordre spécifié.

ScaleTransform(Single, Single)

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

Met à l’échelle la transformation géométrique locale par les quantités spécifiées. Cette méthode précède la matrice de mise à l’échelle de 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 transformation dans la direction de l’axe des x.

sy
Single

Facteur d’échelle de transformation dans la direction de 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
Source:
PathGradientBrush.cs
Source:
PathGradientBrush.cs

Met à l’échelle la transformation géométrique locale par les quantités spécifiées dans l’ordre spécifié.

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 transformation dans la direction de l’axe des x.

sy
Single

Facteur d’échelle de transformation dans la direction de l’axe y.

order
MatrixOrder

Une MatrixOrder qui spécifie s’il faut ajouter ou prépender la matrice de mise à l’échelle.

Exemples

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

  • Crée un chemin d’accès graphique et ajoute un rectangle à celui-ci.

  • 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 la plupart des formes).

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

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

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

  • Appelle la méthode TranslateTransform 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 à