keharriso / love-nuklear

Lightweight immediate mode GUI for LÖVE games
MIT License
350 stars 32 forks source link

nk.line draws faulty lines #22

Closed megagrump closed 5 years ago

megagrump commented 7 years ago

To accurately draw lines in love, it is required to offset the coordinates by .5. nk_love_draw_polyline() causes issues with accurate line rendering, because it ignores this rule and draws lines at integer coordinates.

This is a rectangle drawn with love.graphics.line:

function love.draw()
    love.graphics.setLineWidth(1.0)
    love.graphics.line(10.5, 10.5, 100.5, 10.5, 100.5, 100.5, 10.5, 100.5, 10.5, 10.5)
end

love rectangle

This is the same rectangle drawn with nk.line:

if nk.windowBegin("window", 0, 0, 200, 200) then
    love.graphics.setLineWidth(1.0)
    nk.line(10.5, 10.5, 100, 10, 100.5, 100.5, 10.5, 100.5, 10.5, 10.5)
end
nk.windowEnd()

nuklear rectangle

Both rectangles should look identical, with a thickness of 1 pixel. The one drawn by nk.line is 2 pixels wide. It's not possible to draw lines with a thickness of 1 with nk.line.

keharriso commented 5 years ago

This should be fixed in master and ready for the next release.