这是我的做法:
我正在使用具有两位精度的定点值(我们必须管理半点和半点的平方值)
如上一个答案所述,我也使用平方值而不是平方根。
首先,我在圆的1/8部分中检测到圆的边界限制。 我正在使用这些点的对称性绘制圆的4个“边界”。 然后,我在圆圈内绘制正方形。
与中点圆算法不同,该算法将在直径均匀的情况下工作(并且在实数直径情况下也有一些变化)。
如果我的解释不清楚,请原谅我,我是法国人;)
void DrawFilledCircle(int circleDiameter, int circlePosX, int circlePosY)
{
const int FULL = (1 << 2);
const int HALF = (FULL >> 1);
int size = (circleDiameter << 2);// fixed point value for size
int ray = (size >> 1);
int dY2;
int ray2 = ray * ray;
int posmin,posmax;
int Y,X;
int x = ((circleDiameter&1)==1) ? ray : ray - HALF;
int y = HALF;
circlePosX -= (circleDiameter>>1);
circlePosY -= (circleDiameter>>1);
for (;; y+=FULL)
{