DDA circle drawing algorithm in computer graphics

DDA circle drawing algorithm in computer graphics ,COMPUTER GRAPHICS,MSBTE,PROGRAM DDA,DDA circle drawing algorithm in computer graphics ,22318

 Computer Graphics

C Program for DDA circle drawing algorithm

#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<math.h>


void circl(int xc,int yc,int rad)
{
int x=0,y=rad,p=1-rad;

void plot(int,int,int,int);
plot(xc,yc,x,y);
while(x<y)
{
x++;
if(p< 0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
plot(xc,yc,x,y);
}
}

void plot(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,1);
putpixel(xc-x,yc+y,1);
putpixel(xc+x,yc-y,1);
putpixel(xc-x,yc-y,1);
putpixel(xc+y,yc+x,1);
putpixel(xc-y,yc+x,1);
putpixel(xc+y,yc-x,1);
putpixel(xc-y,yc-x,1);
}

 void main()
 {
int xc,yc,r;
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"T:\\BGI");
printf("Enter the center coordinates and radius\n");
scanf("%d%d%d",&xc,&yc,&r);
setbkcolor(BLACK);
setcolor(WHITE);
circl(xc,yc,r);
getch();
closegraph();

 }
I am Vishal Chavare , I'm a coder, animater. I'm extremely fond of anything related to education, animation & coding. I aim to reach my creative goals one step at a time I believe everyth…

Post a Comment

Solved Manual

© Computer Diploma Third Semester. All rights reserved. DMCA.com Protection Status