布雷森汉姆算法
可能的重复:
如何使用以下命令创建任意粗细的线布雷森纳姆?
如何使用 Bresenham 算法绘制超过像素粗的线条? 我是否必须使用 x 和 y 的偏移量多次运行该算法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以做的一件事是使用直线的斜率(两个正交方向上的单位偏移量)进行计算。将其乘以厚度,然后计算两个端点的偏移量。现在您实际上已经有了旋转矩形的边界。然后,不要使用 Bresenham 来绘制线条,而是使用快速多边形填充。
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.
不,简单的方法就是在算法生成的每个(x,y)位置绘制一个大于一个像素的模板,例如光盘。
但从多次绘制同一个像素的意义上来说,这当然是低效的。然而,它很容易实现,并且即使在奇形或多色模板上也能稳定工作。
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.