Recent Posts
None | 34 sec ago
None | 1 min ago
C# | 1 min ago
None | 2 min ago
None | 3 min ago
C# | 4 min ago
None | 4 min ago
None | 5 min ago
None | 6 min ago
None | 7 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Mani S on the 5th of Jul 2009 01:00:11 AM Download | Raw | Embed | Report
  1. #include<graphics.h>
  2. #include<stdlib.h>
  3. #include<iostream.h>
  4. #include<conio.h>
  5. #include<dos.h>
  6. #define ROUND(a)((int)(a+0.5))
  7. void dda(int,int,int,int);
  8. void main( )
  9. {
  10. int gd=DETECT,gm;
  11. int x1,y1,x2,y2;
  12. initgraph(&gd,&gm,"d:\myc\bgi");
  13. cout<<"Enter the starting and ending co-ordinate of line:";
  14. cin>>x1>>y1>>x2>>y2;
  15. dda(x1,y1,x2,y2);
  16. getch( );
  17. }
  18.  
  19. void dda(int xa,int ya,int xb,int yb)
  20. {
  21. int dx,dy,step,k;
  22. float xinc,yinc,x,y;
  23. dx=xb-xa;
  24. dy=yb-ya;
  25. if(abs(dx)>abs(dy))
  26. step=abs(dx);
  27. else
  28. step=abs(dy);
  29. xinc=dx/(float)step;
  30. yinc=dy/(float)step;
  31. x=xa;
  32. y=ya;
  33. putpixel(ROUND(x),ROUND(y),1);
  34. for(k=1;k<=step;k++)
  35. {
  36. x=x+xinc;
  37. y=y+yinc;
  38. delay(10);
  39. putpixel(ROUND(x),ROUND(y),1);
  40. }
  41. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: