PLOTTING A PIXEL USING C PROGRAM
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
//***PROGRAM FOR DDA LINE DRAWING ALGORITHM***// #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<process.h> #include<math.h> #define ROUND(a) ((int)(a+1)) void lineDDA(int xa,int ya, int xb, int yb) { int dx= xb-xa, dy=yb-ya,steps, k; float xIncrement,yIncrement,x=xa,y=ya; if(abs(dx)>abs(dy)) steps= abs(dx); else steps= abs (dy); xIncrement = dx/(float) steps; yIncrement = dy/(float) steps; putpixel (ROUND(x),ROUND (y),5); for (k=0;k<steps;k++) { x+=xIncrement; y+=yIncrement; putpixel(ROUND(x),ROUND(y),5); } } void main() { int a1,a2,b1,b2; int gdriver= DETECT, gmode; initgraph (&gdriver,&gmode,"c:\\tc\\bgi"); printf("ENTER THE STARTING POSITION"); scanf("%d%d",&a1,&a2); printf("ENTER THE ENDING POSITION"); scanf("%d%d",&b1,&b2); lineDDA(a1,b1,a2,b2); getch(); closegraph(); getch(); }
0 comments:
Post a Comment