Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<graphics.h>
- #include<math.h>
- #include<dos.h>
- #include<conio.h>
- int ROUND(float a){
- a=a+0.5;
- return ((int)a);
- }
- void lineDDA(int x1, int y1, int x2, int y2){
- int dx=x2-x1,dy=y2-y1, steps, k;
- float xincrement, yincrement, x=x1, y=y1;
- 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++){
- delay(50);
- x+=xincrement;
- y+=yincrement;
- putpixel (ROUND(x), ROUND(y), 5);
- }
- }
- void main()
- {
- int x1,y1,x2,y2,gmode,gdriver=DETECT;
- initgraph(&gdriver, &gmode,"C:\\TURBOC3\\BGI");
- printf("Enter the Start point.");
- scanf("%d%d",&x1,&y1);
- printf("Enter the End point.");
- scanf("%d%d",&x2,&y2);
- clrscr();
- lineDDA(x1,y1,x2,y2);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement