c# / 2D Graphics / DrawRectangle size beheviour

427 views Asked by At
private void Form1_Paint(object sender, PaintEventArgs e)
{
    Pen p = new Pen(Brushes.Black, 1);
    e.Graphics.DrawRectangle(p, 3, 3, 89, 30);
}

Why does this code produce a 90px width / 31px height box? i.e one pixel bigger than requested. BTW: FillRectangle works fine.

1

There are 1 answers

2
NickLH On

I imagine that it is because the command defines the inside size of the rectangle and draws the border around that.