快速算法绘制实心圆?实心、算法、快速

2023-09-10 23:28:05 作者:佐笾 単铒环﹎!

我使用布氏圈算法快速圆圈绘制。不过,我也想(在用户的要求下)绘制一个实心的圆。

I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle.

是否有这样做的一种快速有效的方法是什么?沿着布氏同一行的东西?

Is there a fast and efficient way of doing this? Something along the same lines of Bresenham?

我使用的语言是C。

推荐答案

在读对布氏的维基百科页面(也中点)圈算法,这样看来,最容易做的事情是修改自己的行动,而不是这样

Having read the Wikipedia page on Bresenham's (also 'Midpoint') circle algorithm, it would appear that the easiest thing to do would be to modify its actions, such that instead of

setPixel(x0 + x, y0 + y);
setPixel(x0 - x, y0 + y);

和类似的,每次你做,而不是

and similar, each time you instead do

lineFrom(x0 - x, y0 + y, x0 + x, y0 + y);

也就是说,对于每对点(具有相同)的布氏将您有您剧情,而不是你的跟线

That is, for each pair of points (with the same y) that Bresenham would you have you plot, you instead connect with a line.