BRESENHAM'S LINE DRAWING PROGRAM IN C
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
- 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
/* 1<=m<infinity */ #include<stdio.h> #include<conio.h> #include<graphics.h> void linebres(int xa,int ya,int xb,int yb); void main() { int gd=DETECT,gm,xa,ya,xb,yb; initgraph(&gd,&gm,"c:\\tc\\bgi"); printf("Enter the first cordinates:"); scanf("%d%d",&xa,&ya); printf("Enter the last cordinates:"); scanf("%d%d",&xb,&yb); linebres(xa,ya,xb,yb); getch(); } void linebres(int xa,int ya,int xb,int yb) { int dx=xb-xa,dy=yb-ya,n; int p=2*dx-dy; int p1=2*dx; int p2=2*(dx-dy); int x,y,yend; if(ya>yb) { x=xb; y=yb; yend=ya; } else { x=xa; y=ya; yend=yb; } putpixel(x,y,n); while(y<yend) { y++; if(p<0) p+=p1; else { x++; p+=p2; } putpixel(x,y,3); //putpixel(x+3,y,5); } }
0 comments:
Post a Comment