love icon indicating copy to clipboard operation
love copied to clipboard

Unexpected behavior of love.graphics.line with duplicate points

Open megagrump opened this issue 3 years ago • 3 comments

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.

megagrump avatar Jan 03 '22 18:01 megagrump

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.

slime73 avatar Jan 03 '22 21:01 slime73

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.

radgeRayden avatar Jan 03 '22 22:01 radgeRayden

pgimeno did a bit of investigation into the problem, here: https://love2d.org/forums/viewtopic.php?f=3&t=92555

slime73 avatar Jan 23 '22 04:01 slime73

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).

slime73 avatar Sep 19 '22 01:09 slime73