Region.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í.
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
Výjimky
matrix
je null
.
Příklady
Následující příklad kódu je určen pro použití s model Windows Forms a vyžaduje PaintEventArgse
, což je parametr obslužné rutiny Paint události. Kód provede následující akce:
Vytvoří obdélník a nakreslí ho na obrazovku modře.
Vytvoří oblast z obdélníku.
Vytvoří transformační matici a nastaví ji na 45 stupňů.
Použije transformaci na oblast.
Vyplní transformovanou oblast červenou barvou a nakreslí transformovanou oblast na obrazovku červeně.
Všimněte si, že červený obdélník je otočený o 45 stupňů od původního obdélníku zobrazeného modře.
public:
void TransformExample( PaintEventArgs^ e )
{
// Create the first rectangle and draw it to the screen in blue.
Rectangle regionRect = Rectangle(100,50,100,100);
e->Graphics->DrawRectangle( Pens::Blue, regionRect );
// Create a region using the first rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
// Create a transform matrix and set it to have a 45 degree
// rotation.
Matrix^ transformMatrix = gcnew Matrix;
transformMatrix->RotateAt( 45, Point(100,50) );
// Apply the transform to the region.
myRegion->Transform(transformMatrix);
// Fill the transformed region with red and draw it to the screen
// in red.
SolidBrush^ myBrush = gcnew SolidBrush( Color::Red );
e->Graphics->FillRegion( myBrush, myRegion );
}
public void TransformExample(PaintEventArgs e)
{
// Create the first rectangle and draw it to the screen in blue.
Rectangle regionRect = new Rectangle(100, 50, 100, 100);
e.Graphics.DrawRectangle(Pens.Blue, regionRect);
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Create a transform matrix and set it to have a 45 degree
// rotation.
Matrix transformMatrix = new Matrix();
transformMatrix.RotateAt(45, new Point(100, 50));
// Apply the transform to the region.
myRegion.Transform(transformMatrix);
// Fill the transformed region with red and draw it to the screen
// in red.
SolidBrush myBrush = new SolidBrush(Color.Red);
e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)
' Create the first rectangle and draw it to the screen in blue.
Dim regionRect As New Rectangle(100, 50, 100, 100)
e.Graphics.DrawRectangle(Pens.Blue, regionRect)
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Create a transform matrix and set it to have a 45 degree
' rotation.
Dim transformMatrix As New Matrix
transformMatrix.RotateAt(45, New PointF(100, 50))
' Apply the transform to the region.
myRegion.Transform(transformMatrix)
' Fill the transformed region with red and draw it to the
' screen in red.
Dim myBrush As New SolidBrush(Color.Red)
e.Graphics.FillRegion(myBrush, myRegion)
End Sub
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