Solving the pixel-perfect line issue: split line drawing functions
There are two conflicting issues with line drawing in Love2D. These come from two different groups who want to use them:
One group wants line drawing to be pixel perfect. To draw a horizontal line, they want to say
love.graphics.line(40, 50, 80, 50)And if the line-width is one, they want a line to appear on the screen exactly 40 pixels from the top, and that line should be exactly one pixel in width.
This would also include rectangle drawing. The command
love.graphics.rectangle("line", 40, 40, 20, 20)with a line-width of 1 should draw a rectangular outline that is exactly 20 pixels tall. The pixels on the half-open range [40, 60) should be set; pixel 60 should not be set.
The second group wants non-integer transforms to properly affect line drawing. They want to zoom in, scale around, rotate, translate, and have everything look "correct", all on non-integer transforms.
In older versions of Love2D, Group 1 were the ones who (more or less) got what they wanted. The resolution to bug
#153 effectively gave group 2 what they wanted at the expense of group 1. And recent WONTFIX's like #365 suggest that the Love2D developers have sided with group 2 for the near future.
It seems obvious to me that neither side can both get what they want from the same functions. So... why not give the users the choice?
Leave the current functions as they are, but add
pixelLine, and so forth functions. These functions will:
Use the OpenGL-provided line-width and line rendering code.
Perform any +0.5 offsetting that is needed to ensure that lines with a thickness 1 are properly respected.
pixelRectangle, perform any rectangle size shrinkage needed to ensure that pixels outside of the rectangle are not filled in (if the line-width is 1. If it's larger, all bets are off). The other
pixelfunctions should not attempt to perform such shrinkage.
This way, the behavior of every function is well-understood. Each group can get at the functionality they need.