Freigeben über


PathGradientBrush.ScaleTransform Methode

Definition

Skaliert die lokale geometrische Transformation um die angegebenen Beträge. Diese Methode stellt die Skalierungsmatrix der Transformation voran.

Überlädt

ScaleTransform(Single, Single)

Skaliert die lokale geometrische Transformation um die angegebenen Beträge. Diese Methode stellt die Skalierungsmatrix der Transformation voran.

ScaleTransform(Single, Single, MatrixOrder)

Skaliert die lokale geometrische Transformation um die angegebenen Mengen in der angegebenen Reihenfolge.

ScaleTransform(Single, Single)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Skaliert die lokale geometrische Transformation um die angegebenen Beträge. Diese Methode stellt die Skalierungsmatrix der Transformation voran.

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)

Parameter

sx
Single

Der Transformationsmaßstabfaktor in der X-Achsenrichtung.

sy
Single

Der Transformationsskalafaktor in der Richtung der Y-Achse.

Beispiele

Ein Beispiel finden Sie unter ScaleTransform.

Gilt für:

ScaleTransform(Single, Single, MatrixOrder)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Skaliert die lokale geometrische Transformation um die angegebenen Mengen in der angegebenen Reihenfolge.

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)

Parameter

sx
Single

Der Transformationsmaßstabfaktor in der X-Achsenrichtung.

sy
Single

Der Transformationsskalafaktor in der Richtung der Y-Achse.

order
MatrixOrder

Ein MatrixOrder, der angibt, ob die Skalierungsmatrix angefügt oder vorangestellt werden soll.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, ein OnPaint-Ereignisobjekt. Der Code

  • Erstellt einen Grafikpfad und fügt ihr ein Rechteck hinzu.

  • Erstellt eine PathGradientBrush aus den Pfadpunkten (in diesem Beispiel bilden die Punkte ein Rechteck, aber es kann sich um eine beliebige Form handeln).

  • Legt die Mittelfarbe auf Rot und die umgebende Farbe auf Blau fest.

  • Zeichnet die PathGradientBrush vor dem Anwenden der Skalierungstransformation auf den Bildschirm.

  • Wendet die Skalierungstransformation mithilfe der ScaleTransform-Methode auf den Pinsel an.

  • Ruft die TranslateTransform-Methode auf, um das Pinselrechteck so zu verschieben, dass es das zuvor auf dem Bildschirm gezeichnete nicht überlagert.

  • Zeichnet das übersetzte Pinselrechteck auf den Bildschirm.

Beachten Sie, dass das untere Rechteck doppelt so lang in der X-Achse ist, wie die vor der Übersetzung gezeichnete.

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

Gilt für: