Access over 20 million homework & study documents

Bresenham circle drawing algorithm

Content type
User Generated
Subject
Programming
Type
Lab
Rating
Showing Page:
1/2
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gd = DETECT, gm;
int x, xc, y, yc, r, p;
initgraph(&gd, &gm, "C:\\turboc3\\bgi");
printf("Enter xc:\n");
scanf("%d",&xc);
printf("enter yc:\n");
scanf("%d",&yc);
printf("Enter r:\n");
scanf("%d",&r);
x = 0;
y = r;
putpixel(xc,yc,WHITE);
p = 3-(2*r);
while(x<=y)
{
if(p<0)
{
x = x+1;
p = p+(4*x)+6;
}
else
{
x = x+1;
y = y-1;
p = p+(4*x)-(4*y)+10;
}
putpixel(xc+x,yc+y,WHITE); //4
putpixel(xc+x,yc-y,WHITE);//1
putpixel(xc-x,yc+y,WHITE);//5
putpixel(xc-x,yc-y,WHITE);//8
putpixel(xc+y,yc+x,WHITE);//3
putpixel(xc+y,yc-x,WHITE);//2
putpixel(xc-y,yc+x,WHITE);//6
putpixel(xc-y,yc-x,WHITE);//7

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
#include #include #include #include int main(void) { int gd = DETECT, gm; int x, xc, y, yc, r, p; initgraph(&gd, &gm, "C:\\turboc3\\bgi"); printf("Enter xc:\n"); scanf("%d",&xc); printf("enter yc:\n"); scanf("%d",&yc); printf("Enter r:\n"); scanf("%d",&r); x = 0; y = r; putpixel(xc,yc,WHITE); p = 3-(2*r); while(x ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4