Line with different width have different lengths?
-
Given the code below, the first line is drawn 1 pixel longer than the second line (any line where width > 1 is drawn 1 pixel short). Any idea what might be causing this or is this normal behavior? Pen p = new Pen(Color.Black, 1); e.Graphics.DrawLine(p, 10, 10, 10, 100); p = new Pen(Color.Black, 2); e.Graphics.DrawLine(p, 14, 10, 14, 100); p.s. The same thing happens when drawing horizontal lines. Kees
-
Given the code below, the first line is drawn 1 pixel longer than the second line (any line where width > 1 is drawn 1 pixel short). Any idea what might be causing this or is this normal behavior? Pen p = new Pen(Color.Black, 1); e.Graphics.DrawLine(p, 10, 10, 10, 100); p = new Pen(Color.Black, 2); e.Graphics.DrawLine(p, 14, 10, 14, 100); p.s. The same thing happens when drawing horizontal lines. Kees
that is the normal behavior: the pen moves the way you ask it to move; when its size exceeds one, it will hit some pixels before and after the intended trajectory since a pen by default has a circular shape. I guess you can modify both the pen characteristics and the way lines are drawn though, if you really need to. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
that is the normal behavior: the pen moves the way you ask it to move; when its size exceeds one, it will hit some pixels before and after the intended trajectory since a pen by default has a circular shape. I guess you can modify both the pen characteristics and the way lines are drawn though, if you really need to. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.