love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.62k stars 382 forks source link

lineCaps and lineJoins #664

Open slime73 opened 11 years ago

slime73 commented 11 years ago

Original report by Karl Hobley (Bitbucket: kaedroho, GitHub: kaedroho).


lineCaps and lineJoins are very handy as they let you have things like smooth lines. I imagine the implementation won't be that easy but it will improve the quality of LOVE games. This is a feature found in HTML5 canvases

Heres a couple of HTML5 tutorials describing how these are done in HTML5

slime73 commented 11 years ago

Original comment by Matthias Richter (Bitbucket: vrld, GitHub: vrld).


Line-join-modes have been on my to-do for some time, thogh only as 'none' (equivalent to several calls to love.graphics.line()), 'miter' (as it is now) and 'bevel' (see also here). A round line join could probably be added to the list too, though it wouldn't play too nice with the internal implementation - especially with anti-aliasing.

Similar things go for line caps: A square cap is simple enough, but the round one is more complicated.

slime73 commented 11 years ago

Original comment by Karl Hobley (Bitbucket: kaedroho, GitHub: kaedroho).


In my game, I got "round" line caps by simply drawing circles at each end of the line and it actually looks alright. Obviously not a great solution though but it might work as a temporary fix

slime73 commented 10 years ago

Original comment by Matthias Richter (Bitbucket: vrld, GitHub: vrld).


Half of it fixed as of a9e1ef3

slime73 commented 9 years ago

Original comment by SpotlightKid (Bitbucket: SpotlightKid, GitHub: SpotlightKid).


I get this error when trying to use love.graphics.getLineJoin():

Error: main.lua:89: Unknown line join
stack traceback:
    [C]: in function 'getLineJoin'
    main.lua:89: in function 'draw'
    [string "boot.lua"]:438: in function <[string "boot.lua"]:399>
    [C]: in function 'xpcall'

Manjaro Linux x86_64 with LÖVE installed from package manager (love 0.9.1-1)

slime73 commented 9 years ago

Original comment by Sasha Szpakowski (Bitbucket: slime73, GitHub: slime73).


That's already fixed for LÖVE 0.9.2.

slime73 commented 9 years ago

Original comment by SpotlightKid (Bitbucket: SpotlightKid, GitHub: SpotlightKid).


Ah, ok. I only searched the changelog for the function name so I missed the entry.

slime73 commented 9 years ago

Original comment by Sasha Szpakowski (Bitbucket: slime73, GitHub: slime73).


In the meantime adding this to the top of your main.lua should make getLineJoin work as expected, I think: love.graphics.setLineJoin("miter").

slime73 commented 9 years ago

Original comment by SpotlightKid (Bitbucket: SpotlightKid, GitHub: SpotlightKid).


Yes, I figured that out. Since I'm using getLineJoin in a function to save an unknown state, I did this at the top of the module:

if not pcall(love.graphics.getLineJoin) then
    love.graphics.setLineJoin('miter')
end
slime73 commented 7 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


860 was marked as a duplicate of this issue.

slime73 commented 7 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


1146 was marked as a duplicate of this issue.