Graphics.TranslateClip 方法

定義

透過所指定之水平和垂直方向的量,轉譯這個 Graphics 的裁剪區域。

多載

TranslateClip(Int32, Int32)

透過所指定之水平和垂直方向的量,轉譯這個 Graphics 的裁剪區域。

TranslateClip(Single, Single)

透過所指定之水平和垂直方向的量,轉譯這個 Graphics 的裁剪區域。

TranslateClip(Int32, Int32)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

透過所指定之水平和垂直方向的量,轉譯這個 Graphics 的裁剪區域。

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

參數

dx
Int32

這個轉譯的 X 座標。

dy
Int32

這個轉譯的 Y 座標。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 建立裁剪區域的矩形。

  • 將裁剪區域設定為矩形。

  • 依向量 (50、50) 轉譯裁剪區域。

  • 使用實心黑色筆刷填滿大型矩形。

結果是轉譯的小型黑色矩形。

public:
   void TranslateClipInt( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      Rectangle clipRect = Rectangle(0,0,100,100);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Translate clipping region.
      int dx = 50;
      int dy = 50;
      e->Graphics->TranslateClip( dx, dy );

      // Fill rectangle to demonstrate translated clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void TranslateClipInt(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 100, 100);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Translate clipping region.
    int dx = 50;
    int dy = 50;
    e.Graphics.TranslateClip(dx, dy);

    // Fill rectangle to demonstrate translated clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub TranslateClipInt(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New Rectangle(0, 0, 100, 100)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Translate clipping region.
    Dim dx As Integer = 50
    Dim dy As Integer = 50
    e.Graphics.TranslateClip(dx, dy)

    ' Fill rectangle to demonstrate translated clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用於

TranslateClip(Single, Single)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

透過所指定之水平和垂直方向的量,轉譯這個 Graphics 的裁剪區域。

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

參數

dx
Single

這個轉譯的 X 座標。

dy
Single

這個轉譯的 Y 座標。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 建立裁剪區域的矩形。

  • 將裁剪區域設定為矩形。

  • 依向量轉譯裁剪區域 (50.0F、50.0F) 。

  • 使用實心黑色筆刷填滿大型矩形。

結果是轉譯的小型黑色矩形。

public:
   void TranslateClipFloat( PaintEventArgs^ e )
   {
      // Create rectangle for clipping region.
      RectangleF clipRect = RectangleF(0.0F,0.0F,100.0F,100.0F);

      // Set clipping region of graphics to rectangle.
      e->Graphics->SetClip( clipRect );

      // Translate clipping region.
      float dx = 50.0F;
      float dy = 50.0F;
      e->Graphics->TranslateClip( dx, dy );

      // Fill rectangle to demonstrate translated clip region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Black ), 0, 0, 500, 300 );
   }
private void TranslateClipFloat(PaintEventArgs e)
{

    // Create rectangle for clipping region.
    RectangleF clipRect = new RectangleF(0.0F, 0.0F, 100.0F, 100.0F);

    // Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect);

    // Translate clipping region.
    float dx = 50.0F;
    float dy = 50.0F;
    e.Graphics.TranslateClip(dx, dy);

    // Fill rectangle to demonstrate translated clip region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
}
Private Sub TranslateClipFloat(ByVal e As PaintEventArgs)

    ' Create rectangle for clipping region.
    Dim clipRect As New RectangleF(0.0F, 0.0F, 100.0F, 100.0F)

    ' Set clipping region of graphics to rectangle.
    e.Graphics.SetClip(clipRect)

    ' Translate clipping region.
    Dim dx As Single = 50.0F
    Dim dy As Single = 50.0F
    e.Graphics.TranslateClip(dx, dy)

    ' Fill rectangle to demonstrate translated clip region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
    500, 300)
End Sub

適用於