Posts

Showing posts with the label algorithm

BRESENHAMs Line Drawing Algorithm

BRESENHAMs Line Drawing Algorithm using namespace std; #include<iostream> #include<graphics.h> #include<math.h> class BRES {     int xmid,ymid;     float x1,y1,x2,y2; public :     void quad();     void simple(float,float,float,float);     void dot(float,float,float,float);     void dash(float,float,float,float);     void dashdot(float,float,float,float);     void thick(float,float,float,float,int); }; void BRES :: quad() {     int xmax=640,ymax=480;     int gd=DETECT,gm;     initgraph(&gd,&gm,NULL);     xmid=xmax/2;     ymid=ymax/2;     line(0,ymid,xmax,ymid);     line(xmid,0,xmid,ymax); } void BRES :: simple(float x1,float y1,float x2,float y2) {     int i,j,p,x,y;     float dx,dy;     dx = (x2 ...

Bresenhams Line Drawing Algorithm in OpenGL C code

Bresenhams Line Drawing Algorithm in OpenGL C code //Author: Azhar Khan //Rajasthan Technical University //Poornima Institute of Engineering And Technology # include < GL/glut.h > # include < windows.h > # include < stdio.h > GLint x0 , y0 , xEnd , yEnd ; void init ( ) {     glClearColor ( 1.0 , 1.0 , 1.0 , 0.0 ) ;     glColor3f ( 1.0 f , 0.0 f , 0.0 f ) ;     glPointSize ( 1.0 ) ;     glMatrixMode ( GL_PROJECTION ) ;     glLoadIdentity ( ) ;     gluOrtho2D ( 0.0 , 600.0 , 0.0 , 600.0 ) ; } void setPixel ( GLint xcoordinate , GLint ycoordinate ) {     glBegin ( GL_POINTS ) ;     glVertex2i ( xcoordinate , ycoordinate ) ;     glEnd ( ) ;     glFlush ( ) ; } void lineBA ( GLint x0 , GLint y0 , GLint xEnd , GLint yEnd ) {     GLint dx = xEnd - x0 ;     GLint dy = yEnd - y0 ; ...