Graphics Anti-Aliasing and Thickness

Hi.

Is there any way to disable the anti-aliasing when drawing/filling various shapes?

The following line:

g.drawLine(Line<float>(5.0f, 2.0f, 1.0f, 6.0f), 1.0f);

Results in:

I really like to only see a 1-pixel thick line.
It works fine with drawVerticalLine and drawHorizontalLine…

Also, why is the outcome of the following line of code:

g.drawLine(Line<float>(1.0f, 3.0f, 8.0f, 3.0f), 1.0f);

Is a 2-pixel thick line?

Where the same line drawn with drawHorizontalLine looks ok:

g.drawHorizontalLine(3.0f, 1.0f, 8.0f);

Thanks.

No, there’s no way to turn off anti-aliasing, and these days you shouldn’t be even considering it if you’re writing properly vector-based scalable UIs. If you care about this stuff, you’re probably sitting too close to the screen.

And think about what a line is. It’s actually a rectangle, 1 pixel wide. So if you draw a line that is centred at y=3, it will actually cover the range 2.5 to 3.5, which will be smudged across 2 pixels. If you want it to lie within a single pixel, you could either draw it at y = 2.5, so that it goes from 2.0 to 3.0, or better still, use a rectangle, because what you’re trying to draw isn’t really a line at all, it’s a 1-pixel high rectangle.

I’m sure this topic has been raised many many times before, and people have drawn nice diagrams to explain it, but I can’t seem to find any of them.

I have been finally able to find the way to do a drawDashedLine with a height of exactly 1 pixel when I have seen this subject ! :lol:

Would it be possible to write in the JUCE documentation that a line centered between say 2 and 3 must have its position centered at 2.5 to have the right height ? This is logical in a way, but at the same time this is something I wouldn’t have been able to understand without this subject…

Thanks in advance !