drawLine bug?


#1

While coding on my LookAndFeel code, I found out that:

[code]const int w = header.getWidth();
const int h = header.getHeight();

g.drawLine (Line(Point(0,h-1),Point(w,h-1)),1);[/code]

and

[code]const int w = header.getWidth();
const int h = header.getHeight();

g.drawLine (Line(Point(0,h-1),Point(w,h-1)));[/code]

does not draw the same line. In the first example, the resulting line is exactly 2 pixels in height. In the second example it is one pixel in height.

Is this normal?


#2

I’m curious if it still draws a 2 pixel line if you do;

?


#3

Yes, it does. Why shouldn’t it anyway? The integer 1 is being converted to 1.0f anyway…


#4

That is actually deliberate - the one that takes a thickness draws a “correct” line, using paths, so it’s sub-pixel accurate but slow. The other one draws a quick-and-dirty 1-pixel line, which is best for integer-aligned coords.


#5

subpixel accurate but not single-pixel accurate, eh? :wink: