Glusk / sprouts

A multi-platform implementation of Sprouts, built with libGDX.
MIT License
1 stars 1 forks source link

Smooth line joins #38

Closed Glusk closed 5 years ago

Glusk commented 5 years ago

libGDX provides no line joining utilities/settings.

Line joins

http://www.bluevoid.com/opengl/sig00/advanced00/notes/node290.html

The following SO answer shows how to compute Milter join points (in general terms, although the question was about libGDX in specific).

An easy round join solution:

Draw a circle centered at the common vertex with radius half the line width. Sounds easy but if not drawn carefully, there would be serious overdraw.

http://artgrammer.blogspot.com/search/label/opengl


If drawing a curve, a texture can be applied to triangle strips. Example:

Texture

https://badlogicgames.com/forum/viewtopic.php?f=11&t=18940 (The forum was shut down).

Glusk commented 5 years ago

Update

libGDX renders lines using OpenGL.

One of the sad things about using the OpenGL rendering option in Processing is the lack of control over line weights, caps and joins.

http://www.tom-carden.co.uk/2008/02/09/new-processing-hack-line-caps-and-joins-in-opengl

Unfortunately, drawing lines is a weak point of OpenGL. The GL_LINES drawing mode is limited: it does not support line joins, line caps, non-integer line widths, widths greater than 10px, or varying widths in a single pass.

https://blog.mapbox.com/drawing-antialiased-lines-with-opengl-8766f34192dc

Glusk commented 5 years ago

Maybe the simple solution is still good enough: Draw a circle centered at the common vertex with radius half the line width.