PathGradientBrush.ScaleTransform Metod

Definition

Skalar den lokala geometriska transformen efter de angivna beloppen. Den här metoden förbereder skalningsmatrisen till transformeringen.

Överlagringar

Name Description
ScaleTransform(Single, Single)

Skalar den lokala geometriska transformen efter de angivna beloppen. Den här metoden förbereder skalningsmatrisen till transformeringen.

ScaleTransform(Single, Single, MatrixOrder)

Skalar den lokala geometriska transformen efter de angivna beloppen i den angivna ordningen.

ScaleTransform(Single, Single)

Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs

Skalar den lokala geometriska transformen efter de angivna beloppen. Den här metoden förbereder skalningsmatrisen till transformeringen.

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)

Parametrar

sx
Single

Transformeringsskalningsfaktorn i x-axelns riktning.

sy
Single

Transformeringsskalningsfaktorn i y-axelns riktning.

Exempel

Ett exempel finns i ScaleTransform.

Gäller för

ScaleTransform(Single, Single, MatrixOrder)

Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs
Källa:
PathGradientBrush.cs

Skalar den lokala geometriska transformen efter de angivna beloppen i den angivna ordningen.

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)

Parametrar

sx
Single

Transformeringsskalningsfaktorn i x-axelns riktning.

sy
Single

Transformeringsskalningsfaktorn i y-axelns riktning.

order
MatrixOrder

En MatrixOrder som anger om skalningsmatrisen ska läggas till eller förberedas.

Exempel

Följande kodexempel är utformat för användning med Windows Forms och kräver PaintEventArgse, ett OnPaint händelseobjekt. Koden

  • Skapar en grafiksökväg och lägger till en rektangel i den.

  • Skapar en PathGradientBrush från sökvägspunkterna (i det här exemplet bildar punkterna en rektangel, men det kan vara de flesta former).

  • Ställer in mittenfärgen till röd och den omgivande färgen till blå.

  • PathGradientBrush Ritar till skärmen innan skalningstransformen tillämpas.

  • Tillämpar skalningstransformen på penseln med hjälp av dess ScaleTransform metod.

  • TranslateTransform Anropar metoden för att flytta penselrektangeln så att den inte lägger över den som ritades till skärmen tidigare.

  • Ritar den översatta penselrektangeln till skärmen.

Observera att den nedre rektangeln är dubbelt så lång i x-axeln som den som ritades före översättningen.

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

Gäller för