Graphics.TranslateClip Method

Definition

Translates the clipping region of this Graphics by specified amounts in the horizontal and vertical directions.

Overloads

TranslateClip(Int32, Int32)

Translates the clipping region of this Graphics by specified amounts in the horizontal and vertical directions.

TranslateClip(Single, Single)

Translates the clipping region of this Graphics by specified amounts in the horizontal and vertical directions.

TranslateClip(Int32, Int32)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Translates the clipping region of this Graphics by specified amounts in the horizontal and vertical directions.

C#
public void TranslateClip(int dx, int dy);

Parameters

dx
Int32

The x-coordinate of the translation.

dy
Int32

The y-coordinate of the translation.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a rectangle for the clipping region.

  • Sets the clipping region to the rectangle.

  • Translates the clipping region by a vector (50, 50).

  • Fills a large rectangle with a solid black brush.

The result is a translated, small, black rectangle.

C#
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);
}

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

TranslateClip(Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Translates the clipping region of this Graphics by specified amounts in the horizontal and vertical directions.

C#
public void TranslateClip(float dx, float dy);

Parameters

dx
Single

The x-coordinate of the translation.

dy
Single

The y-coordinate of the translation.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a rectangle for the clipping region.

  • Sets the clipping region to the rectangle.

  • Translates the clipping region by a vector (50.0F, 50.0F).

  • Fills a large rectangle with a solid black brush.

The result is a translated, small, black rectangle.

C#
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);
}

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10