02-bresenhams.txt

  • Uploaded by: muhammad shafiq
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 02-bresenhams.txt as PDF for free.

More details

  • Words: 79
  • Pages: 1
#include #include void drawline(int x1, int y1, int xn, int yn) { int dx, dy, p, x, y; dx=xn-x1; dy=yn-y1; x=x1; y=y1; p=2*dy-dx; while(x1<xn) { if(p>=0) { putpixel(x,y,red); x=x+1; y=y+1; p=p+2*dy-2*dx;

} else {

putpixel(x,y,red);

} }

x=x+1; y=y+0; p=p+2*dy;

}

int main() { int gdriver=DETECT, gmode, error, x1, y1, xn, yn; initgraph(&gdriver, &gmode, " "); cout<<"Enter co-ordinates of first point: "; cin>>x1>>y1; cout<<"Enter co-ordinates of second point: "; cin>>xn>>yn; drawline(x1, y1, xn, yn); closegraph(); delay(5); return 0; }

More Documents from "muhammad shafiq"

02-bresenhams.txt
May 2020 9
June 2020 17
Sutus Product Brochure
June 2020 17
Lecture_no 8 And 12
December 2019 11