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

后端 未结 12 865
不知归路
不知归路 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:38

    The easiest way to create a line of almost arbitrary thickness would be to first do a bresenham, then apply as many dilation iterations as you wish. Each dilation pads both sides of your line equally.

    EDIT: It is also worth noting that this method has the nice feature of being easily generalizable to 3D, because both Bresenham and dilation are easily generalizable to 3D.

    Bresenham → thickness 1:

    Dilation mask:

    0 1 0
    1 1 1
    0 1 0
    

    Bresenham + 1 dilation → thickness 2

    Bresenham + 2 dilations → thickness 3

    etc.

提交回复
热议问题