Similar Programs
- Flood Fill program in C
- Triangle Rotation Program
- Text animation program in C
- C program for fixed point scaling and rotation
- C Program for shearing of triangle, line and rectangle
- C program to plot different types of lines
- Scaling program in C
- Font animation program in C
- Midpoint ellipse drawing program in C
- Circle Midpoint program in C
- Translation program in C
- Bresenhem Circle drawing program in C
- String Generation program in C
- Bresenhem Line drawing program in C
- Plotting a pixel in C
- DDA line drawing program in C
- Boundary fill program in C
- Character Generation program in C
- Triangle Rotation program in C
#include<stdio.h> #include<conio.h> #include<graphics.h> void circlemidpoint(int xc,int yc,int rad); void circleplotpoints(int xc, int yc, int x,int y); //void boundaryfill(int xc,int yc,int fill,int bound); void main() { int gd=DETECT,gm,n,rad,xc,yc,fill,bound; initgraph(&gd,&gm,"../bgi"); printf("Enter the center cordinates:"); scanf("%d%d",&xc,&yc); printf("\n\nEnter the radius"); scanf("%d",&rad); circlemidpoint(xc,yc,rad); // boundaryfill(xc,yc,10,5); getch(); } void circlemidpoint(int xc,int yc,int rad) { int x = 0,y=rad,p=1-rad; void circleplotpoints(int,int,int,int); circleplotpoints(xc,yc,x,y); while(x<y) { x++; if(p<0) p+=2*x+1; else { y--; p+=2*(x-y)+1; } circleplotpoints(xc,yc,x,y); } } void circleplotpoints(int xc, int yc, int x,int y) { delay(100); putpixel(xc+x,yc+y,5); putpixel(xc-x,yc+y,5); putpixel(xc+x,yc-y,5); putpixel(xc-x,yc-y,5); putpixel(xc+y,yc+x,5); putpixel(xc-y,yc+x,5); putpixel(xc+y,yc-x,5); putpixel(xc-y,yc-x,5); } /*void boundaryfill(int xc,int yc,int fill, int bound) { int cur; cur=getpixel(xc,yc); if((cur!=bound) && (cur!=fill)) { setcolor(fill); putpixel(xc,yc,fill); delay(10); boundaryfill(xc+1,yc,fill,bound); boundaryfill(xc-1,yc,fill,bound); boundaryfill(xc,yc+1,fill,bound); boundaryfill(xc,yc-1,fill,bound); } } */
0 comments:
Post a Comment