Region.Translate 方法

定義

將該 Region 座標偏移指定量。

多載

名稱 Description
Translate(Int32, Int32)

將該 Region 座標偏移指定量。

Translate(Single, Single)

將該 Region 座標偏移指定量。

Translate(Int32, Int32)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將該 Region 座標偏移指定量。

public:
 void Translate(int dx, int dy);
public void Translate(int dx, int dy);
member this.Translate : int * int -> unit
Public Sub Translate (dx As Integer, dy As Integer)

參數

dx
Int32

這筆錢是用來橫向抵銷的 Region

dy
Int32

這個數字是用來垂直抵銷的 Region

範例

以下程式碼範例是為 Windows Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:

  • 建立一個矩形並以藍色畫到螢幕上。

  • 從長方形中建立一個區域。

  • 將翻譯應用於該地區。

  • 將平移區域填滿紅色,並將平移區域繪製成紅色。

注意紅色矩形從原本的藍色矩形向下向右移動。

void TranslateExample( 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 );

   // Apply the translation to the region.
   myRegion->Translate( 150, 100 );

   // 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 TranslateExample(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);
             
    // Apply the translation to the region.
    myRegion.Translate(150, 100);
             
    // 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 TranslateExample(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)

    ' Apply the translation to the region.
    myRegion.Translate(150, 100)

    ' 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

適用於

Translate(Single, Single)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將該 Region 座標偏移指定量。

public:
 void Translate(float dx, float dy);
public void Translate(float dx, float dy);
member this.Translate : single * single -> unit
Public Sub Translate (dx As Single, dy As Single)

參數

dx
Single

這筆錢是用來橫向抵銷的 Region

dy
Single

這個數字是用來垂直抵銷的 Region

範例

程式碼範例請參見該 Translate(Single, Single) 方法。

適用於