2

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

How can I use Bresenham algorithm to draw lines of more than a pixel thick? Do i have to run the algorithm many times with an offset from x and y?

Community
  • 1
  • 1
JustCurious
  • 1,848
  • 3
  • 30
  • 57

2 Answers2

2

No, the simple way is just plot a stencil at every (x, y) location produced by the algorithm that is larger than one pixel, e.g. a disc.

But that's of course inefficient in the sense that you plot the same pixel many times. It's however easy to implement and works robustly with even odd-shaped or multicolored stencils.

Antti Huima
  • 25,136
  • 3
  • 52
  • 71
  • Yeah, but (a) the oddshaped stencils are not the question (b) transparency kind-a ruins things (unless you want to also introduce an intermediate layer) – sehe May 01 '11 at 21:58
2

One thing you can do is to calculate using the slope of the line, a unit offset in both orthogonal directions. Multiply this by your thickness, and take the offsets at both endpoints. You now have effectively the bounds of a rotated rectangle. Then, rather than using Bresenham to draw the line, use a fast polygon fill.

Kevin Hsu
  • 1,726
  • 11
  • 14