Csharp/C Sharp/2D Graphics/Point
Add size to a Point
using System;
using System.Drawing;
class Class1 {
[STAThread]
static void Main(string[] args) {
Point topLeft = new Point(10, 10);
Size rectangleSize = new Size(50, 50);
Point bottomRight = topLeft + rectangleSize;
Console.WriteLine("topLeft = " + topLeft);
Console.WriteLine("bottomRight = " + bottomRight);
Console.WriteLine("Size = " + rectangleSize);
}
}
Work with Point type
using System;
using System.Drawing;
class Program {
static void Main(string[] args) {
// Create and offset a point.
Point pt = new Point(100, 72);
Console.WriteLine(pt);
pt.Offset(20, 20);
Console.WriteLine(pt);
// Overloaded Point operators.
Point pt2 = pt;
if (pt == pt2)
Console.WriteLine("Points are the same");
else
Console.WriteLine("Different points");
// Change pt2"s X value.
pt2.X = 4000;
// Now show each X:
Console.WriteLine("First point: {0}", pt);
Console.WriteLine("Second point: {0}", pt2);
}
}