Bresenham Circle Drawing Program in C
BresenhamCircle.txt
File size: 1.18 KB
File content type: text/plain
Category: Practical Files
Subject: Computer Graphics and Multimedia
// Program uses graphics.h that is generally available in Turbo C
#include<stdio.h>
#include<dos.h>
#include<graphics.h>
#include<conio.h>
void main() {
int gd=DETECT, gm=DETECT;
int r, x, y, midx, midy,p;
initgraph(&gd,&gm,"");
printf("Enter the Radius of circle : ");
scanf("%d",&r);
x = 0;
y = r;
p = 3 - 2*r;
midx=getmaxx()/2; //To get the max position (Bottom-Right corner) of screen.
midy=getmaxy()/2; //Dividing by 2 to get the centre of screen.
do {
putpixel(midx+ x, midy+ y , 1); //All possible 8 combinations to draw 8 Segments
putpixel(midx- x, midy- y , 2);
putpixel(midx- x, midy+ y , 3);
putpixel(midx+ x, midy- y , 4);
putpixel(midx +y, midy+ x , 5);
putpixel(midx +y, midy -x , 6);
putpixel(midx -y, midy -x , 7);
putpixel(midx -y, midy +x , 8);
delay(20);
x++; //x will always increase , so it is incremented outside if-else
if(p<0) {
p=p+4*x+6;
}
else {
y--; //y decrements only when p>=0
p=p+4*(x-y)+10;
}
}while(x<=y);
getch();
}
Related searches C Program for Bresenham Circle Drawing Algorithm
Last Updated: July 16, 2022
Related
Chemistry Phase Rule and Water Handwritten Notes PDF
Category: NotesJuly 16, 2022
Power Electronics Complete Notes
Category: NotesJuly 17, 2022
Chemistry Chapter Fuel - Book Pics PDF
Category: NotesJuly 16, 2022
Advance Control System Popov and Circle Criterion
Category: NotesJuly 17, 2022
IPU Introduction to Programming (ITP) Notes Full Semester
Category: NotesJuly 16, 2022
Java Program to check if a number is prime
Category: Practical FilesJuly 16, 2022
Solved Question Paper EHVACDC Akash
Category: Question PapersJuly 17, 2022
Advance Control System Unit 1
Category: NotesJuly 17, 2022
Tower of Hanoi Iterative C
Category: Practical FilesJuly 17, 2022
Engineering Chemistry Jain Jain Book PDF
Category: eBooksJuly 16, 2022