Bresenham 线算法(厚度)

发布于 2024-08-05 00:10:45 字数 436 浏览 5 评论 0原文

我想知道是否有人知道基于 Bresenham 线算法或任何类似算法来绘制特定粗细线的算法。

再一想,我一直想知道对于每个 setPixel(x,y) 我只画一个圆圈,例如:

filledCircle(x,y,thickness);对于每个 x,y 但这当然会非常慢。我也尝试过使用字典,但这很快就会填满记忆。检查我要绘制的像素是否具有相同的颜色,但这对于大型画笔来说也不够有效。

也许我可以根据角度画半圆?

任何意见将不胜感激。

谢谢。

重复: 如何如何使用 Bresenham 创建任意粗细的线?

I was wondering if anyone knew of any algorithm to draw a line with specific thickness, based on Bresenham's line algorithm or any similar.

On a second thought, I've been wondering about for each setPixel(x,y) I'd just draw a circle, e.g.:

filledCircle(x,y,thickness); for every x,y but that would of course be very slow. I also tried to use dictionary but that would fill the memory in no time. Check the pixels I'm about to draw on if they have the same color, but that's also not efficient enough for large brushes.

Perhaps I could somehow draw half circles depending on the angle?

Any input would be appreciated.

Thanks.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

于我来说 2024-08-12 00:10:45

您实际上无法沿着线画圆。此方法已获得专利。 :)
您仍然可以阅读专利来获取灵感。

You cannot actually draw circles along the line. This approach is patented. :)
You can still read patent for inspiration.

终止放荡 2024-08-12 00:10:45

我不知道常用的是什么,但在我看来,您可以将 Bresenham 用于 1 像素宽的线,但将其垂直或水平延伸一定数量的像素。例如,假设您的线与水平线成大约 30 度角,并且您希望它的宽度为 4 个像素。您计算出线条的垂直粗细应为五个像素。您运行 Bresenham,但对于每个像素 (x,y),您实际上绘制 (x,y)、(x,y+1)、...(x,y+4)。如果您希望线的末端变圆,请在每一端画一个圆圈。

对于过度杀伤,制作手写笔的像素图(圆形或对角线笔尖,或其他),然后绘制一组平行的布雷森汉姆线,一条对应手写笔中的每个像素。

I don't know what is commonly used, but it seems to me that you could use Bresenham for the 1-pixel-wide line, but extend it a set number of pixels vertically or horizonally. For instance, suppose your line is roughly 30 degrees away from the horizontal, and you want it to be four pixels wide. You calculate that the vertical thickness of the line should be five pixels. You run Bresenham, but for each pixel (x,y), you actually draw (x,y), (x,y+1), ... (x,y+4). And if you want the ends of the line to be rounded, draw a circle at each end.

For overkill, make a pixel map of the stylus (a circle or diagonal nib, or whatever), then draw a set of parallel Bresenham lines, one for each pixel in the stylus.

绝不放开 2024-08-12 00:10:45

There are variations on Bresenhams which calculate pixel coverage, such as those used in the anti-grain geometry libraries; whether you want something that quality - you don't say what the output medium is, and most systems more capable than on-off LCDS support pens with thickness anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文