我有這個代碼在屏幕上畫一個橢圓,但我不明白這是什麼意思長定義語句,我只想知道如何編寫相同的代碼沒有所有混淆定義語句。這個定義語句是什麼意思?
#define incx() x++, dxt += d2xt, t += dxt
#define incy() y--, dyt += d2yt, t += dyt
void ellipse(int xc, int yc, int rx, int ry, int color)
{
int x = 0, y = ry;
long rx2 = (long)rx*rx, ry2 = (long)ry*ry;
long crit1 = -(rx2/4 + rx%2 + ry2);
long crit2 = -(ry2/4 + ry%2 + rx2);
long crit3 = -(ry2/4 + ry%2);
long t = -rx2*y; // e(x+1/2,y-1/2) - (a^2+b^2)/4
long dxt = 2*ry2*x, dyt = -2*rx2*y;
long d2xt = 2*ry2, d2yt = 2*rx2;
while (y>=0 && x<=rx)
{
pixel(xc+x, yc+y, color);
if (x!=0 || y!=0)
pixel(xc-x, yc-y, color);
if (x!=0 && y!=0)
{
pixel(xc+x, yc-y, color);
pixel(xc-x, yc+y, color);
}
if (t + ry2*x <= crit1 || //e(x+1,y-1/2) <= 0
t + rx2*y <= crit3) //e(x+1/2,y) <= 0
incx();
else if (t - rx2*y > crit2) //e(x+1/2,y-1) > 0
incy();
else
{
incx();
incy();
}
}
}
我試圖刪除定義一塊一塊,它不工作,任何建議?