Line / Thickness Algorithm

I am looking for a fast algorithm that draws lines with a specific thickness. Lines should not be smoothed, speed is a priority. Something pretty simple, as it would be enough:

gWpLL.png

A use case is a Javascript game in which worms leave trails. (HTML5 Canvas clearly draws lines, but getImageData () is very slow and thus collision detection)

I could not find anything that would do this for the last 2.5 hours. And yes, I know that there are almost the same questions on SO, in fact there are quite a lot of them, but none of them have a working solution. The only solution I currently have is to draw circles along the Bresenham line, which is not very efficient.

Some code (pseudo-code, JS, or at least a link to an article) will be great.

+7
javascript algorithm graphics line drawing
source share
1 answer

http://members.chello.at/~easyfilter/bresenham.html

check below. This is a smooth line, but it should be simple enough to modify without smoothing.

+10
source share

All Articles