Matrix.Translate 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 określony wektor translacji do tego Matrix przez poprzedzanie wektora tłumaczenia.
Przeciążenia
Translate(Single, Single) |
Stosuje określony wektor translacji ( |
Translate(Single, Single, MatrixOrder) |
Stosuje określony wektor tłumaczenia do tego Matrix w określonej kolejności. |
Translate(Single, Single)
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
Stosuje określony wektor translacji (offsetX
i offsetY
) do tego Matrix przez poprzedzanie wektora tłumaczenia.
public:
void Translate(float offsetX, float offsetY);
public void Translate (float offsetX, float offsetY);
member this.Translate : single * single -> unit
Public Sub Translate (offsetX As Single, offsetY As Single)
Parametry
Przykłady
Aby zapoznać się z przykładem, zobacz Translate(Single, Single, MatrixOrder).
Dotyczy
Translate(Single, Single, MatrixOrder)
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
- Źródło:
- Matrix.cs
Stosuje określony wektor tłumaczenia do tego Matrix w określonej kolejności.
public:
void Translate(float offsetX, float offsetY, System::Drawing::Drawing2D::MatrixOrder order);
public void Translate (float offsetX, float offsetY, System.Drawing.Drawing2D.MatrixOrder order);
member this.Translate : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Translate (offsetX As Single, offsetY As Single, order As MatrixOrder)
Parametry
- order
- MatrixOrder
Element MatrixOrder określający kolejność (dołączanie lub poprzedzanie), w której translacja jest stosowana do tego Matrixelementu .
Przykłady
Poniższy przykład kodu jest przeznaczony do użytku z Windows Forms i wymaga PaintEventArgse
obiektu Paint zdarzenia . Kod wykonuje następujące akcje:
Rysuje prostokąt na ekranie przed zastosowaniem przekształcenia translate (niebieski prostokąt).
Tworzy macierz i tłumaczy ją o 100 w obu osiach.
Stosuje tę transformację macierzy do prostokąta,
Rysuje przekształcony prostokąt na ekran (czerwony prostokąt).
Zwróć uwagę, że początek czerwonego prostokąta znajduje się 100 punktów na obu osiach od początku niebieskiego trójkąta.
public:
void TranslateExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
// Draw a rectangle to the screen before applying the
// transform.
e->Graphics->DrawRectangle( myPen, 20, 20, 100, 50 );
// Create a matrix and translate it.
Matrix^ myMatrix = gcnew Matrix;
myMatrix->Translate( 100, 100, MatrixOrder::Append );
// Draw the Points to the screen again after applying the
// transform.
e->Graphics->Transform = myMatrix;
e->Graphics->DrawRectangle( myPen2, 20, 20, 100, 50 );
}
public void TranslateExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Draw a rectangle to the screen before applying the
// transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50);
// Create a matrix and translate it.
Matrix myMatrix = new Matrix();
myMatrix.Translate(100, 100, MatrixOrder.Append);
// Draw the Points to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50);
}
Public Sub TranslateExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
' Draw a rectangle to the screen before applying the
' transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50)
' Create a matrix and translate it.
Dim myMatrix As New Matrix
myMatrix.Translate(100, 100, MatrixOrder.Append)
' Draw the Points to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50)
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