love
love copied to clipboard
Unexpected behavior of love.graphics.line with duplicate points
function love.draw()
love.graphics.line(0, 0, 100, 100, 100, 100) -- a
love.graphics.line(0, 0, 50, 50, 50, 50, 100, 100) --b
love.graphics.line(0, 0, 50, 50, 100, 100, 50, 50) -- c
end
I would expect all of these calls to draw a line from 0, 0
to 100, 100
, but neither of them do.
a and b draw nothing. c draws a line from 0, 0
to 50, 50
.
function love.draw()
love.graphics.line(100, 100, 100, 100)
end
Since line coordinates are endpoint-inclusive, I think this should draw a single point at 100, 100
.
Funny backstory: I wasted a considerable amount of time trying to find a bug in a routine that builds a huge graph; turns out all the nodes were actually connected, but some of the lines in the visualisation had duplicate points like this.
For reference, there's a bit of discussion about this in #972. However I haven't decided yet if the same stance should be taken as in the original issue so I might leave this open.
I think especially when we're talking about arbitrarily generated lines, it would be very nice to have a more resilient line drawing function, and in particular the expected behaviour of drawing a point if start and end are the same simplifies things a bit (for the end user). Maybe it is unexpected for other people, though.
pgimeno did a bit of investigation into the problem, here: https://love2d.org/forums/viewtopic.php?f=3&t=92555
This is fixed as of 6b54ee5 (part of love 12, although we could backport the fix I suppose if we end up releasing a new 11.x version).