how do I create a line of arbitrary thickness using Bresenham?

后端 未结 12 870
不知归路
不知归路 2020-12-01 03:31

I am currently using Bresenham\'s algorithm to draw lines but they are (of course) one pixel in thickness. My question is what is the most efficient way to draw lines of arb

12条回答
  •  天涯浪人
    2020-12-01 04:20

    Take another Bresenham loop and use it to modify the start and end position of original line in rectangular direction. Problem is to efficently find the right starting point and not to draw any pixel twice (or skip a pixel) while drawing next line.

    Working and tested C code is available from Github C code .

    Here a test page including a few sample lines created by this code. The black pixels are the starting points for the algorithm.

提交回复
热议问题