Here is my code to create polygon.
I was asked to draw an offset polygon.
If a user enters "50" in text box then a polygon should be drawn with extension of input
in all sides.
Here is my code
Brush drawing_brush = new SolidBrush(Color.Red);
Brush drawing_brush1 = new SolidBrush(Color.Blue);
Pen drawing_pen = new Pen(drawing_brush, 2);
Pen drawing_pen1 = new Pen(drawing_brush1, 2);
Graphics Draw = this.CreateGraphics();
int x = Convert.ToInt32(Width.Text);
int y = Convert.ToInt32(Height.Text);
Point P1 = new Point(x, y);
Point P2 = new Point(x + 100, y);
Point P3 = new Point(x + 100, y + 100);
Point P4 = new Point(x, y + 100);
Point[] P = { P1, P2, P3, P4 };
Draw.DrawPolygon(drawing_pen, P);
Point Q1 = new Point(x - 10, y - 10);
Point Q2 = new Point(x + 110, y - 10);
Point Q3 = new Point(x + 110, y + 110);
Point Q4 = new Point(x - 10, y + 110);
Point[] Q = { Q1, Q2, Q3, Q4 };
Draw.DrawPolygon(drawing_pen1, Q);