Matrix.RotateAt 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.
Stosuje rotację w kierunku wskazówek zegara o określonym punkcie do tego Matrix przez wyprzedanie obrotu.
Przeciążenia
RotateAt(Single, PointF) |
Stosuje do tego Matrix obrót zgodnie z ruchem wskazówek zegara w punkcie określonym w parametrze |
RotateAt(Single, PointF, MatrixOrder) |
Stosuje obrót zgodnie z ruchem wskazówek zegara o określonym punkcie do tego Matrix w określonej kolejności. |
RotateAt(Single, PointF)
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
Stosuje do tego Matrix obrót zgodnie z ruchem wskazówek zegara w punkcie określonym w parametrze point
i przez wstępnego obrotu.
public:
void RotateAt(float angle, System::Drawing::PointF point);
public void RotateAt (float angle, System.Drawing.PointF point);
member this.RotateAt : single * System.Drawing.PointF -> unit
Public Sub RotateAt (angle As Single, point As PointF)
Parametry
- angle
- Single
Kąt (zakres) obrotu, w stopniach.
Przykłady
W poniższym przykładzie kodu pokazano, jak używać metody Matrix i Transform do obracania ciągu. Ten przykład jest przeznaczony do użycia z Windows Forms. Twórca formularz i wklej do niego następujący kod. Wywołaj metodę DrawVerticalStringFromBottomUp
w procedurze obsługi zdarzeń formularza Paint , przekazując e
jako PaintEventArgs.
private:
void DrawVerticalStringFromBottomUp( PaintEventArgs^ e )
{
// Create the string to draw on the form.
String^ text = "Can you read this?";
// Create a GraphicsPath.
System::Drawing::Drawing2D::GraphicsPath^ path = gcnew System::Drawing::Drawing2D::GraphicsPath;
// Add the string to the path; declare the font, font style, size, and
// vertical format for the string.
path->AddString( text, this->Font->FontFamily, 1, 15, PointF(0.0F,0.0F), gcnew StringFormat( StringFormatFlags::DirectionVertical ) );
// Declare a matrix that will be used to rotate the text.
System::Drawing::Drawing2D::Matrix^ rotateMatrix = gcnew System::Drawing::Drawing2D::Matrix;
// Set the rotation angle and starting point for the text.
rotateMatrix->RotateAt( 180.0F, PointF(10.0F,100.0F) );
// Transform the text with the matrix.
path->Transform(rotateMatrix);
// Set the SmoothingMode to high quality for best readability.
e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::HighQuality;
// Fill in the path to draw the string.
e->Graphics->FillPath( Brushes::Red, path );
// Dispose of the path.
delete path;
}
public void DrawVerticalStringFromBottomUp(PaintEventArgs e)
{
// Create the string to draw on the form.
string text = "Can you read this?";
// Create a GraphicsPath.
System.Drawing.Drawing2D.GraphicsPath path =
new System.Drawing.Drawing2D.GraphicsPath();
// Add the string to the path; declare the font, font style, size, and
// vertical format for the string.
path.AddString(text, this.Font.FontFamily, 1, 15,
new PointF(0.0F, 0.0F),
new StringFormat(StringFormatFlags.DirectionVertical));
// Declare a matrix that will be used to rotate the text.
System.Drawing.Drawing2D.Matrix rotateMatrix =
new System.Drawing.Drawing2D.Matrix();
// Set the rotation angle and starting point for the text.
rotateMatrix.RotateAt(180.0F, new PointF(10.0F, 100.0F));
// Transform the text with the matrix.
path.Transform(rotateMatrix);
// Set the SmoothingMode to high quality for best readability.
e.Graphics.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.HighQuality;
// Fill in the path to draw the string.
e.Graphics.FillPath(Brushes.Red, path);
// Dispose of the path.
path.Dispose();
}
Public Sub DrawVerticalStringFromBottomUp(ByVal e As PaintEventArgs)
' Create the string to draw on the form.
Dim text As String = "Can you read this?"
' Create a GraphicsPath.
Dim path As New System.Drawing.Drawing2D.GraphicsPath
' Add the string to the path; declare the font, font style, size, and
' vertical format for the string.
path.AddString(text, Me.Font.FontFamily, 1, 15, New PointF(0.0F, 0.0F), _
New StringFormat(StringFormatFlags.DirectionVertical))
' Declare a matrix that will be used to rotate the text.
Dim rotateMatrix As New System.Drawing.Drawing2D.Matrix
' Set the rotation angle and starting point for the text.
rotateMatrix.RotateAt(180.0F, New PointF(10.0F, 100.0F))
' Transform the text with the matrix.
path.Transform(rotateMatrix)
' Set the SmoothingMode to high quality for best readability.
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
' Fill in the path to draw the string.
e.Graphics.FillPath(Brushes.Red, path)
' Dispose of the path.
path.Dispose()
End Sub
Dotyczy
RotateAt(Single, PointF, MatrixOrder)
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
Stosuje obrót zgodnie z ruchem wskazówek zegara o określonym punkcie do tego Matrix w określonej kolejności.
public:
void RotateAt(float angle, System::Drawing::PointF point, System::Drawing::Drawing2D::MatrixOrder order);
public void RotateAt (float angle, System.Drawing.PointF point, System.Drawing.Drawing2D.MatrixOrder order);
member this.RotateAt : single * System.Drawing.PointF * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub RotateAt (angle As Single, point As PointF, order As MatrixOrder)
Parametry
- angle
- Single
Kąt obrotu w stopniach.
- order
- MatrixOrder
Element MatrixOrder określający kolejność (dołączanie lub wstępnego), w którym jest stosowana rotacja.
Przykłady
Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse
Paint obiektu zdarzenia . Kod wykonuje następujące akcje:
Rysuje prostokąt na ekranie przed zastosowaniem przekształcenia obrotu (niebieski prostokąt).
Tworzy macierz i obraca ją o 45 stopni wokół określonego punktu.
Stosuje tę transformację macierzy do prostokąta.
Rysuje przekształcony prostokąt na ekran (czerwony prostokąt).
Zwróć uwagę, że czerwony prostokąt został obrócony wokół lewego górnego rogu prostokąta (punkt rotacji określił metodę RotateAt ).
public:
void RotateAtExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
PointF rotatePoint = PointF(150.0f,50.0f);
// Draw the rectangle to the screen before applying the
// transform.
e->Graphics->DrawRectangle( myPen, 150, 50, 200, 100 );
// Create a matrix and rotate it 45 degrees.
Matrix^ myMatrix = gcnew Matrix;
myMatrix->RotateAt( 45, rotatePoint, MatrixOrder::Append );
// Draw the rectangle to the screen again after applying the
// transform.
e->Graphics->Transform = myMatrix;
e->Graphics->DrawRectangle( myPen2, 150, 50, 200, 100 );
}
public void RotateAtExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
PointF rotatePoint = new PointF(150.0f, 50.0f);
// Draw the rectangle to the screen before applying the
// transform.
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100);
// Create a matrix and rotate it 45 degrees.
Matrix myMatrix = new Matrix();
myMatrix.RotateAt(45, rotatePoint, MatrixOrder.Append);
// Draw the rectangle to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100);
}
Public Sub RotateAtExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
Dim rotatePoint As New PointF(150.0F, 50.0F)
' Draw the rectangle to the screen before applying the
' transform.
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100)
' Create a matrix and rotate it 45 degrees.
Dim myMatrix As New Matrix
myMatrix.RotateAt(45, rotatePoint, MatrixOrder.Append)
' Draw the rectangle to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100)
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