Matrix.RotateAt Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Applique une rotation dans le sens des aiguilles d'une montre et par rapport au point spécifié à ce Matrix en l'ajoutant au début.
Surcharges
RotateAt(Single, PointF) |
Applique une rotation dans le sens des aiguilles d'une montre et par rapport au point spécifié par le paramètre Matrix à ce |
RotateAt(Single, PointF, MatrixOrder) |
Applique une rotation dans le sens des aiguilles d'une montre et par rapport au point spécifié à ce Matrix dans l'ordre spécifié. |
RotateAt(Single, PointF)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
Applique une rotation dans le sens des aiguilles d'une montre et par rapport au point spécifié par le paramètre Matrix à ce point
en l'ajoutant au début.
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)
Paramètres
- angle
- Single
Angle (étendue) de la rotation, en degrés.
Exemples
L’exemple de code suivant illustre l’utilisation d’une Matrix et de la Transform méthode pour faire pivoter une chaîne. Cet exemple est conçu pour être utilisé avec Windows Forms. Create un formulaire et collez-y le code suivant. Appelez la DrawVerticalStringFromBottomUp
méthode dans le gestionnaire d’événements du Paint formulaire, en passant comme e
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
S’applique à
RotateAt(Single, PointF, MatrixOrder)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
Applique une rotation dans le sens des aiguilles d'une montre et par rapport au point spécifié à ce Matrix dans l'ordre spécifié.
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)
Paramètres
- angle
- Single
Angle de la rotation, en degrés.
- order
- MatrixOrder
MatrixOrder qui spécifie l'ordre (ajout au début ou à la fin) dans lequel la rotation est appliquée.
Exemples
L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse
, un objet d’événementPaint. Le code effectue les actions suivantes :
Dessine un rectangle vers l’écran avant d’appliquer une transformation de rotation (rectangle bleu).
Crée une matrice et la fait pivoter de 45 degrés autour d’un point spécifié.
Applique cette transformation matricielle au rectangle.
Dessine le rectangle transformé à l’écran (rectangle rouge).
Notez que le rectangle rouge a été pivoté autour du coin supérieur gauche du rectangle (le point de rotation a spécifié la RotateAt méthode).
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
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour