Lines with large values sometimes have unexpected line width

I was scaling some polygons with some large values and noticed some lines were not rendered properly when I was setting the line width.

white = playdate.graphics.kColorWhite
black = playdate.graphics.kColorBlack

local polyReference = playdate.geometry.polygon.new(-100, 50, 500, 50)
local polyIssue = playdate.geometry.polygon.new(-33782, 150, 33782, 150)

function playdate.update()
	playdate.graphics.clear( black )

	playdate.graphics.setColor( white )
	playdate.graphics.setLineWidth(3)
	playdate.graphics.drawPolygon(polyReference)
	playdate.graphics.drawPolygon(polyIssue)
	playdate.graphics.drawLine(-33782, 200, 33782, 200)
end

lineIssue
The top line is the reference and use the proper line width of 3 pixels. The bottom one are larger than that.

The issue doesn’t happened when the line width is set to 1.

fixed! Typical integer overflow problem, dx and dy were ints here: float d = dx*dx+dy*dy;

1 Like