Ler em inglês

Compartilhar via


Matrix.RotateAt Método

Definição

Aplica uma rotação no sentido horário sobre o ponto especificado a esse Matrix, acrescentando a rotação.

Sobrecargas

RotateAt(Single, PointF)

Aplica uma rotação no sentido horário a essa Matrix ao redor do ponto especificado no parâmetro point e anexando a rotação.

RotateAt(Single, PointF, MatrixOrder)

Aplica uma rotação no sentido horário sobre o ponto especificado a esse Matrix na ordem especificada.

RotateAt(Single, PointF)

Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs

Aplica uma rotação no sentido horário a essa Matrix ao redor do ponto especificado no parâmetro point e anexando a rotação.

public void RotateAt (float angle, System.Drawing.PointF point);

Parâmetros

angle
Single

O ângulo (extensão) da rotação, em graus.

point
PointF

Um PointF que representa o centro da rotação.

Exemplos

O exemplo de código a seguir demonstra o uso de um Matrix e o método Transform para girar uma cadeia de caracteres. Este exemplo foi projetado para ser usado com o Windows Forms. Crie um formulário e cole o código a seguir nele. Chame o método DrawVerticalStringFromBottomUp no manipulador de eventos Paint do formulário, passando e como PaintEventArgs.

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();
}

Aplica-se a

.NET 9 e outras versões
Produto Versões
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

RotateAt(Single, PointF, MatrixOrder)

Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs

Aplica uma rotação no sentido horário sobre o ponto especificado a esse Matrix na ordem especificada.

public void RotateAt (float angle, System.Drawing.PointF point, System.Drawing.Drawing2D.MatrixOrder order);

Parâmetros

angle
Single

O ângulo da rotação, em graus.

point
PointF

Um PointF que representa o centro da rotação.

order
MatrixOrder

Um MatrixOrder que especifica a ordem (acréscimo ou prefixo) na qual a rotação é aplicada.

Exemplos

O exemplo de código a seguir foi projetado para uso com o Windows Forms e requer PaintEventArgse, um objeto de evento Paint. O código executa as seguintes ações:

  • Desenha um retângulo na tela antes de aplicar uma transformação de rotação (o retângulo azul).

  • Cria uma matriz e gira-a 45 graus em torno de um ponto especificado.

  • Aplica essa transformação de matriz ao retângulo.

  • Desenha o retângulo transformado para a tela (o retângulo vermelho).

Observe que o retângulo vermelho foi girado ao redor do canto superior esquerdo do retângulo (o ponto de rotação especificou o método RotateAt).

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);
}

Aplica-se a

.NET 9 e outras versões
Produto Versões
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9