This document contains the code for drawing an ellipse using the Mid-Point circle algorithm. It includes functions to plot points and the main logic to iterate through the points to draw the ellipse. The algorithm uses incremental calculations to determine the x and y coordinates of points on the ellipse as it moves out from the center.
This document contains the code for drawing an ellipse using the Mid-Point circle algorithm. It includes functions to plot points and the main logic to iterate through the points to draw the ellipse. The algorithm uses incremental calculations to determine the x and y coordinates of points on the ellipse as it moves out from the center.
void plotpoints(int cx, int cy, int x, int y) { putpixel(cx + x, cy + y, 4); putpixel(cx - x, cy + y, 4); putpixel(cx + x, cy - y, 4); putpixel(cx - x, cy - y, 4); }
void main() { int cx, cy, rx, ry;
printf("Enter the center "); scanf("%d%d", &cx, &cy); printf("x radius : "); scanf("%d", &rx); printf("y radius : "); scanf("%d", &ry);
long rx2 = (long) rx * rx; long ry2 = (long) ry * ry; long trx2 = 2 * rx2; long try2 = 2 * ry2; long p, x = 0, y = ry; long px = 0; long py = trx2 * y;