0% found this document useful (0 votes)
30 views3 pages

Mid Point Ellipse Drawing Algorithm

The document contains a C program that implements the Mid Point Ellipse Drawing Algorithm using basic graphics operations. It prompts the user for the center coordinates and the x and y radii of the ellipse, then calculates and draws the ellipse using pixel plotting. The program also includes additional graphics operations such as drawing lines and displaying text at specific coordinates.

Uploaded by

Subhadra
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)
30 views3 pages

Mid Point Ellipse Drawing Algorithm

The document contains a C program that implements the Mid Point Ellipse Drawing Algorithm using basic graphics operations. It prompts the user for the center coordinates and the x and y radii of the ellipse, then calculates and draws the ellipse using pixel plotting. The program also includes additional graphics operations such as drawing lines and displaying text at specific coordinates.

Uploaded by

Subhadra
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

C Program for Mid Point Ellipse

Drawing Algorithm
1

Program #include<conio.h> #include<stdio.h>

#include<graphics.h> void main() { int gd=DETECT,gm;

float x,y,xc,yc...

C Program of Basic Graphics Operation II

C Program for Digital Differential Analyzer Algorithm


(DDA)

C Program for Mid Point Circle Drawing

Program

#include<conio.h>

#include<stdio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm;

float x,y,xc,yc,rx,ry,pk,pk1;

clrscr();

initgraph(&gd,&gm,"..\\bgi");

printf("Mid point ellipse drawing algorithm\n");

printf("Enter Center for ellipse\nx : ");

scanf("%f",&xc);

printf("y : ");

scanf("%f",&yc);

printf("Enter x-radius and y-radius\nx-radius : ");

scanf("%f",&rx);

printf("y-radius : ");

scanf("%f",&ry);

x=0;

y=ry;

pk=(ry*ry)-(rx*rx*ry)+((rx*rx)/4);

while((2*x*ry*ry)<(2*y*rx*rx))

if(pk<=0)

{
x=x+1;

pk1=pk+(2*ry*ry*x)+(ry*ry);

else

x=x+1;

y=y-1;

pk1=pk+(2*ry*ry*x)-(2*rx*rx*y)+(ry*ry);

pk=pk1;

putpixel(xc+x,yc+y,2);

putpixel(xc-x,yc+y,2);

putpixel(xc+x,yc-y,2);

putpixel(xc-x,yc-y,2);

pk=((x+0.5)*(x+0.5)*ry*ry)+((y-1)*(y-1)*rx*rx)-(rx*rx*ry*ry);

while(y>0)

if(pk>0)

y=y-1;

pk1=pk-(2*rx*rx*y)+(rx*rx);

else

x=x+1;

y=y-1;

pk1=pk+(2*ry*ry*x)-(2*rx*rx*y)+(rx*rx);

pk=pk1;

putpixel(xc+x,yc+y,2);

putpixel(xc-x,yc+y,2);

putpixel(xc+x,yc-y,2);

putpixel(xc-x,yc-y,2);

line(xc+rx,yc,xc-rx,yc);
line(xc,yc+ry,xc,yc-ry);

outtextxy(xc+(1.2*rx),yc-(1.2*ry),"(x,y)");

outtextxy(xc-(1.2*rx),yc+(1.2*ry),"(-x,-y)");

outtextxy(xc+(1.2*rx),yc+(1.2*ry),"(x,-y)");

outtextxy(xc-(1.2*rx),yc-(1.2*ry),"(-x,y)");

getch();

Output

You might also like