GraphicsPath.Transform(Matrix) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Použije transformační matici na tento GraphicsPathobjekt .
public:
void Transform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Transform (System.Drawing.Drawing2D.Matrix matrix);
member this.Transform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Transform (matrix As Matrix)
Parametry
Příklady
Následující příklad kódu je navržený pro použití s model Windows Forms a vyžaduje PaintEventArgse
objekt OnPaint události . Kód provede následující akce:
Vytvoří cestu a přidá do cesty tři tečky.
Nakreslí cestu k obrazovce.
Vytvoří transformační matici pro překlad cesty 100 jednotek ve směru osy X.
Nakreslí transformovanou cestu na obrazovku.
Všimněte si, že původní elipsa je nakreslená černě a transformovaná elipsa červeně.
private:
void TransformExample( PaintEventArgs^ e )
{
// Create a path and add and ellipse.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddEllipse( 0, 0, 100, 200 );
// Draw the starting position to screen.
e->Graphics->DrawPath( Pens::Black, myPath );
// Move the ellipse 100 points to the right.
Matrix^ translateMatrix = gcnew Matrix;
translateMatrix->Translate( 100, 0 );
myPath->Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e->Graphics->DrawPath( gcnew Pen( Color::Red,2.0f ), myPath );
}
private void TransformExample(PaintEventArgs e)
{
// Create a path and add and ellipse.
GraphicsPath myPath = new GraphicsPath();
myPath.AddEllipse(0, 0, 100, 200);
// Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath);
// Move the ellipse 100 points to the right.
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(100, 0);
myPath.Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)
' Create a path and add and ellipse.
Dim myPath As New GraphicsPath
myPath.AddEllipse(0, 0, 100, 200)
' Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath)
' Move the ellipse 100 points to the right.
Dim translateMatrix As New Matrix
translateMatrix.Translate(100, 0)
myPath.Transform(translateMatrix)
' Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(New Pen(Color.Red, 2), myPath)
End Sub
Poznámky
Transformace může škálovat, překládat, otáčet nebo zkosit GraphicsPath.
Platí pro
Váš názor
https://aka.ms/ContentUserFeedback.
Připravujeme: V průběhu roku 2024 budeme postupně vyřazovat problémy z GitHub coby mechanismus zpětné vazby pro obsah a nahrazovat ho novým systémem zpětné vazby. Další informace naleznete v tématu:Odeslat a zobrazit názory pro