Edit

Share via


PointF.Add Method

Definition

Translates a given PointF by the specified size.

Overloads

Add(PointF, Size)

Translates a given PointF by the specified Size.

Add(PointF, SizeF)

Translates a given PointF by a specified SizeF.

Add(PointF, Size)

Source:
PointF.cs
Source:
PointF.cs
Source:
PointF.cs

Translates a given PointF by the specified Size.

C#
public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.Size sz);

Parameters

pt
PointF

The PointF to translate.

sz
Size

The Size that specifies the numbers to add to the coordinates of pt.

Returns

The translated PointF.

Remarks

The Add method adds the Width of the specified size to the x-coordinate of the PointF and the Height to the y-coordinate of the PointF.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 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, 2.1

Add(PointF, SizeF)

Source:
PointF.cs
Source:
PointF.cs
Source:
PointF.cs

Translates a given PointF by a specified SizeF.

C#
public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.SizeF sz);

Parameters

pt
PointF

The PointF to translate.

sz
SizeF

The SizeF that specifies the numbers to add to the coordinates of pt.

Returns

The translated PointF.

Examples

The following code example demonstrates how to use the Add method. To run this example, paste the following code into a Windows Form. Handle the form's Paint event and call AddExample, passing e as PaintEventArgs.

C#
private void AddExample(PaintEventArgs e)
{
    PointF point1 = new PointF(120.5F, 120F);
    SizeF size1 = new SizeF(20.5F, 20.5F);
    RectangleF rect1 = new RectangleF(point1, size1);
    PointF point2 = new PointF(rect1.Right, rect1.Bottom);
    if (point2 != PointF.Add(point1, size1))
        e.Graphics.DrawString("They are not equal", this.Font, Brushes.Red, rect1);
    else
        e.Graphics.DrawString("They are equal", this.Font, Brushes.Black, rect1);
}

Remarks

The Add method adds the Width of the specified size to the x-coordinate of the PointF and the Height to the y-coordinate of the PointF.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 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, 2.1