123 Eng

### Engineering the engineers™

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

Computer Science / IT
Electronics
Electrical
Mechanical
Chemical
Civil

CAT / MBA

GMAT / Foreign MBA
Latest Jobs

Displaying  Source Code(s)

 Program to implement Line Clipping Algorithm. -------------------------------------------------------------------------------- #include #include #include #include #include #include int pixels[2][4]; float xn1,xn2,yn1,yn2,x3,y3,m; void show_quadrant() { cleardevice(); rectangle(120,40,320,240); rectangle(320,40,520,240); rectangle(120,240,320,440); rectangle(320,240,520,440); for(int i=130;i<=510;i+=10) { if(i==320) continue; outtextxy(i,237,"+"); } for(i=50;i<=430;i+=10) { if(i==240) continue; outtextxy(317,i,"-"); } outtextxy(310,230,"O"); outtextxy(530,240,"X"); outtextxy(320,450,"-Y"); outtextxy(100,240,"-X"); outtextxy(320,30,"Y"); } void su_co(int x1,int y1,int x2,int y2,int xmin,int ymin,int xmax,int ymax) { int i,j,fl; for(i=0;i<2;i++) for(j=0;j<4;j++) pixels[i][j]=0; if(y1>ymax) pixels[0][0]=1; if(y1xmax) pixels[0][2]=1; if(x1ymax) pixels[1][0]=1; if(y2xmax) pixels[1][2]=1; if(x2ymax) pixels[0][0]=1; if(y1xmax) pixels[0][2]=1; if(x1ymax) pixels[1][0]=1; if(y2xmax) pixels[1][2]=1; if(x2ymax || y1xmax || x1ymax || y3xmax || x3ymax || y2xmax || x2ymax || y3xmax || x3=11;i++,j--) { gotoxy(xx,1); cout<" Sutherland-Cohen ""; cout<<" 2:==>" Mid-Point Method ""; cout<<" 3:==>" Exit ""; cout<<" " Enter Your Choice ":="; cin>>choice; switch(choice) { case 1: initgraph(&gd,&gm,"..\bgi"); clearviewport(); show_quadrant(); line(320+xmin,240-ymin,320+xmin,240-ymax); line(320+xmin,240-ymax,320+xmax,240-ymax); line(320+xmax,240-ymax,320+xmax,240-ymin); line(320+xmax,240-ymin,320+xmin,240-ymin); line (320+x1,240-y1,320+x2,240-y2); getch(); cleardevice(); show_quadrant(); line(320+xmin,240-ymin,320+xmin,240-ymax); line(320+xmin,240-ymax,320+xmax,240-ymax); line(320+xmax,240-ymax,320+xmax,240-ymin); line(320+xmax,240-ymin,320+xmin,240-ymin); su_co(x1,y1,x2,y2,xmin,ymin,xmax,ymax); getch(); break; case 2: initgraph(&gd,&gm,"..\bgi"); clearviewport(); show_quadrant(); line(320+xmin,240-ymin,320+xmin,240-ymax); line(320+xmin,240-ymax,320+xmax,240-ymax); line(320+xmax,240-ymax,320+xmax,240-ymin); line(320+xmax,240-ymin,320+xmin,240-ymin); line (320+x1,240-y1,320+x2,240-y2); getch(); cleardevice(); show_quadrant(); line(320+xmin,240-ymin,320+xmin,240-ymax); line(320+xmin,240-ymax,320+xmax,240-ymax); line(320+xmax,240-ymax,320+xmax,240-ymin); line(320+xmax,240-ymin,320+xmin,240-ymin); midpt(x1,y1,x2,y2,xmin,ymin,xmax,ymax); getch(); break; case 3: exit(0); default: cout<<" a" Press A Valid Key...!!! ""; getch(); main(); break; } closegraph(); }

Contribute content or training reports / feedback / Comments
job placement papers