# All your Engineering Programs at one place

It’s not that easy to complete an experiment in 2 hours’ lab. Sometimes you finish up writing a program within just 15 minutes & sometimes even a whole week’s time is not enough to do so. We’re Engineers, we don’t need to copy everything word by word, but we need that one kick start. Once we get started, it’s tough to stop us. There are … Continue reading All your Engineering Programs at one place

# Liang Barsky Line Clipping Algorithm (C++)

#include <conio.h> #include <iostream.h> #include <graphics.h> void main(){ int gdriver = DETECT, gmode; initgraph(&gdriver,&gmode,”C:\TC\BGI”); setcolor(BLUE); int xl,yl,xh,yh; cout<<“Enter bottom left and top right co-ordinates of the window: “; cin>>xl>>yl>>xh>>yh; rectangle(xl,yl,xh,yh); int x1,y1,x2,y2; cout<<“Enter endpoints of the line: “; cin>>x1>>y1>>x2>>y2; line(x1,y1,x2,y2); getch(); int p[4],q[4],i,accept=1;                               // To decide if line has to … Continue reading Liang Barsky Line Clipping Algorithm (C++)

# Flood Fill Algorithm (C++)

#include <iostream.h> #include <conio.h> #include <graphics.h> #include <dos.h> void ffill(int x,int y,int o_col,int n_col){ int current = getpixel(x,y); if(current==o_col){ delay(1); putpixel(x,y,n_col); ffill(x+1,y,o_col,n_col); ffill(x-1,y,o_col,n_col); ffill(x,y+1,o_col,n_col); ffill(x,y-1,o_col,n_col); } } void main(){ int xc,yc,r; int gdriver = DETECT,gmode; initgraph(&gdriver,&gmode,”C:\TC\BGI”); cout<<“Enter co-ordinates of the centre: “; cin>>xc>>yc; cout<<“Enter radius of circle: “; cin>>r; circle(xc,yc,r); cout<<“Press any key to fill circle…”; getch(); ffill(xc,yc,BLACK,RED); getch(); closegraph(); } Continue reading Flood Fill Algorithm (C++)