0% found this document useful (0 votes)
20 views4 pages

20BCA1290 Computer Graphics Worsheet1.4

The document provides instructions for a computer graphics practical to scan convert an ellipse using the midpoint ellipse algorithm. It includes the aim, task to be performed, concepts, steps, and code to draw an ellipse given center points and major and minor axis as input.

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

20BCA1290 Computer Graphics Worsheet1.4

The document provides instructions for a computer graphics practical to scan convert an ellipse using the midpoint ellipse algorithm. It includes the aim, task to be performed, concepts, steps, and code to draw an ellipse given center points and major and minor axis as input.

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

INSTRUCTIONS

Student Name: Davansh Choudhary UID: 20BCA1290


Branch: BCA Section/Group 20BCA3/b
Semester: 5th Date of Performance:2/9/22
Subject Name computer graphics Subject Code:20CAP-316

1. Aim/Overview of the practical:  Scan Convert a ellipse with centre (100, 50) and
and major axis=50 , minor axis=30  using Midpoint Ellipse Algorithm
2. Task to be done:  Scan Convert a ellipse with centre (100, 50) and and major axis=50 ,
minor axis=30  using Midpoint Ellipse Algorithm
3. Concept used: mid -point algorithm
4. Steps/Commands involved to perform practical:
5. #include<stdio.h>
6. #include<conio.h>
7. #include<graphics.h>
8.
9. void ellipse(int xc,int yc,int rx,int ry)
10. {
11. int gm=DETECT,gd;
12. int x, y, p;
13. clrscr();
14. initgraph(&gm,&gd,"C:\\TC\\BGI");
15. x=0;
16. y=ry;
17. p=(ry*ry)-(rx*rx*ry)+((rx*rx)/4);
18. while((2*x*ry*ry)<(2*y*rx*rx))
19. {
20. putpixel(xc+x,yc-y,WHITE);
21. putpixel(xc-x,yc+y,WHITE);
22. putpixel(xc+x,yc+y,WHITE);
23. putpixel(xc-x,yc-y,WHITE);
24.
25. if(p<0)
26. {
27. x=x+1;
28. p=p+(2*ry*ry*x)+(ry*ry);
29. }
30. else
31. {
32. x=x+1;
33. y=y-1;
34. p=p+(2*ry*ry*x+ry*ry)-(2*rx*rx*y);
35. }
36. }
37. p=((float)x+0.5)*((float)x+0.5)*ry*ry+(y-1)*(y-1)*rx*rx-rx*rx*ry*ry;
38.
39. while(y>=0)
40. {
41. putpixel(xc+x,yc-y,WHITE);
42. putpixel(xc-x,yc+y,WHITE);
43. putpixel(xc+x,yc+y,WHITE);
44. putpixel(xc-x,yc-y,WHITE);
45.
46. if(p>0)
47. {
48. y=y-1;
49. p=p-(2*rx*rx*y)+(rx*rx);
50.
51. }
52. else
53. {
54. y=y-1;
55. x=x+1;
56. p=p+(2*ry*ry*x)-(2*rx*rx*y)-(rx*rx);
57. }
58. }
59. getch();
60. closegraph();
61. }
62.
63. void main()
64. {
65. int xc,yc,rx,ry;
66. clrscr();
67. printf("Enter Xc=");
68. scanf("%d",&xc);
69. printf("Enter Yc=");
70. scanf("%d",&yc);
71. printf("Enter Rx=");
72. scanf("%d",&rx);
73. printf("Enter Ry=");
74. scanf("%d",&ry);
75. ellipse(xc,yc,rx,ry);
76. getch();
77. }
78. OUTPUT:-

79.Learning outcomes (What I have learnt):

1.

2.

3.

You might also like