PathGradientBrush.ScaleTransform Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Skaluje lokalną transformację geometryczną według określonych kwot. Ta metoda poprzedza macierz skalowania do przekształcenia.
Przeciążenia
ScaleTransform(Single, Single) |
Skaluje lokalną transformację geometryczną według określonych kwot. Ta metoda poprzedza macierz skalowania do przekształcenia. |
ScaleTransform(Single, Single, MatrixOrder) |
Skaluje lokalną transformację geometryczną według określonych kwot w określonej kolejności. |
ScaleTransform(Single, Single)
- Źródło:
- PathGradientBrush.cs
- Źródło:
- PathGradientBrush.cs
- Źródło:
- PathGradientBrush.cs
Skaluje lokalną transformację geometryczną według określonych kwot. Ta metoda poprzedza macierz skalowania do przekształcenia.
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)
Parametry
- sx
- Single
Współczynnik skalowania transformacji w kierunku osi x.
- sy
- Single
Współczynnik skalowania transformacji w kierunku osi y.
Przykłady
Aby zapoznać się z przykładem, zobacz ScaleTransform.
Dotyczy
ScaleTransform(Single, Single, MatrixOrder)
- Źródło:
- PathGradientBrush.cs
- Źródło:
- PathGradientBrush.cs
- Źródło:
- PathGradientBrush.cs
Skaluje lokalną transformację geometryczną według określonych kwot w określonej kolejności.
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)
Parametry
- sx
- Single
Współczynnik skalowania transformacji w kierunku osi x.
- sy
- Single
Współczynnik skalowania transformacji w kierunku osi y.
- order
- MatrixOrder
Element MatrixOrder określający, czy należy dołączyć lub wstępnie uzupełnić macierz skalowania.
Przykłady
Poniższy przykład kodu jest przeznaczony do użytku z Windows Forms i wymaga PaintEventArgse
obiektu OnPaint zdarzenia . Kod
Tworzy ścieżkę grafiki i dodaje do niej prostokąt.
Tworzy obiekt PathGradientBrush na podstawie punktów ścieżki (w tym przykładzie punkty tworzą prostokąt, ale może to być najbardziej dowolny kształt).
Ustawia kolor środkowy na czerwony i otaczający kolor na niebieski.
Rysuje ekran PathGradientBrush przed zastosowaniem przekształcenia skalowania.
Stosuje przekształcenie skalowania do pędzla przy użyciu jego ScaleTransform metody.
Wywołuje metodę TranslateTransform , aby przenieść prostokąt pędzla, tak aby nie nakładał się na niego wcześniej narysowany na ekranie.
Rysuje przetłumaczony prostokąt pędzla na ekranie.
Zwróć uwagę, że dolny prostokąt jest dwa razy dłuższy na osi x, tak jak ten narysowany przed tłumaczeniem.
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
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla