I have this code to draw an ellipse in the screen but i dont understand what does it means the long define statement, and i only want to know how to write the same code without all that confuse define statement.
#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();
}
}
}
I have tried to remove the define piece by piece and it dont work, any suggestion?