CS602 Assignment1
CS602 Assignment1
01 Total Marks: 20
Semester: Spring 2023
Due Date: 23nd May
CS602: Computer Graphics 2023
https://www.youtube.com/@virtualkitaab
YouTube:
TASK Marks=20
Suppose you are working on a project where you need to draw an ellipse of a given
center point (xc,yc), major axis length (a), and minor axis length (b) using the
Midpoint Ellipse Drawing Algorithm in C++. Write a program to implement the
algorithm and display the resulting ellipse. Then fill the Ellipse with any color and
design using the graphics libraries.
Note: You should display your student ID before displaying the Ellipse.
Solution:
#include <graphics.h>
int main()
{
//initialize graphics window
initwindow(640, 480, "Ellipse Drawing Algorithm");
//display student ID
outtextxy(10, 10, "Student ID: [insert ID here]");
if (d < 0)
d += (b * b * (2 * x + 3));
else
{
d += ((b * b * (2 * x + 3)) + (a * a * (-2 * y + 2)));
y--;
}
x++;
}
if (d > 0)
d += (a * a * (-2 * y + 3));
else
{
d += ((b * b * (2 * x + 2)) + (a * a * (-2 * y + 3)));
x++;
}
y--;
}
return 0;
}