PathGradientBrush.ScaleTransform Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menskalakan transformasi geometrik lokal dengan jumlah yang ditentukan. Metode ini menambahkan matriks penskala ke transformasi.
Overload
ScaleTransform(Single, Single) |
Menskalakan transformasi geometrik lokal dengan jumlah yang ditentukan. Metode ini menambahkan matriks penskala ke transformasi. |
ScaleTransform(Single, Single, MatrixOrder) |
Menskalakan transformasi geometrik lokal dengan jumlah yang ditentukan dalam urutan yang ditentukan. |
ScaleTransform(Single, Single)
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
Menskalakan transformasi geometrik lokal dengan jumlah yang ditentukan. Metode ini menambahkan matriks penskala ke transformasi.
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
Faktor skala transformasi dalam arah sumbu x.
- sy
- Single
Faktor skala transformasi ke arah sumbu y.
Contoh
Misalnya, lihat ScaleTransform.
Berlaku untuk
ScaleTransform(Single, Single, MatrixOrder)
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
- Sumber:
- PathGradientBrush.cs
Menskalakan transformasi geometrik lokal dengan jumlah yang ditentukan dalam urutan yang ditentukan.
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
Faktor skala transformasi dalam arah sumbu x.
- sy
- Single
Faktor skala transformasi ke arah sumbu y.
- order
- MatrixOrder
MatrixOrder yang menentukan apakah akan menambahkan atau menambahkan matriks penskalakan terlebih dahulu.
Contoh
Contoh kode berikut dirancang untuk digunakan dengan Windows Forms, dan memerlukan PaintEventArgse
, objek peristiwa OnPaint. Kode
Membuat jalur grafis dan menambahkan persegi panjang ke dalamnya.
Membuat PathGradientBrush dari titik jalur (dalam contoh ini, titik membentuk persegi panjang, tetapi bisa menjadi bentuk apa pun).
Mengatur warna tengah ke merah dan warna sekitarnya menjadi biru.
Menggambar PathGradientBrush ke layar sebelum menerapkan transformasi skala.
Menerapkan transformasi skala ke kuas dengan menggunakan metode ScaleTransform.
Memanggil metode TranslateTransform untuk memindahkan persegi panjang kuas sehingga tidak melapisi yang digambar ke layar sebelumnya.
Menggambar persegi panjang kuas yang diterjemahkan ke layar.
Perhatikan bahwa persegi panjang bawah dua kali lebih panjang dalam sumbu x seperti yang digambar sebelum terjemahan.
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