开发者

Bresenham algorithm [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

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

How can I use Bresenham algorithm to dr开发者_如何转开发aw lines of more than a pixel thick? Do i have to run the algorithm many times with an offset from x and y?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜