Showing posts with label Computer Graphics. Show all posts
Showing posts with label Computer Graphics. Show all posts

Tuesday, December 26, 2017

Program for 2D reflection along Y-axis (using graphics.h)

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include<math.h> int main() {             int gm;             int gd=DETECT;             int x1,x2,x3,y1,y2,y3;   //initgraph(&gd,&gm,"c:\tc\bg:");      ...

Program for 2D reflection in C along X-axis (using graphics.h)

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include<math.h> int main() {             int gm;             int gd=DETECT;             int x1,x2,x3,y1,y2,y3;   //initgraph(&gd,&gm,"c:\tc\bg:");      ...

Program for 2D schearing in C (using graphics.h)

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include<math.h> int main() {             int gm;             int gd=DETECT;             int x1,x2,x3,y1,y2,y3,nx1,nx2,nx3,ny1,ny2,ny3;             int shx,shy;              initwindow(1200,600);    ...

Program for 2D scaling in c (using graphics.h)

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include<math.h> int main() {             int gm;             int gd=DETECT;             int x1,x2,x3,y1,y2,y3;             int sx,sy;              initwindow(1200,600);            ...

Program for 2D translation in C (using graphics.h)

#include <graphics.h> #include <stdlib.h> #include <stdio.h> #include<math.h> int main() {             int gm;             int gd=DETECT;             int x1,x2,x3,y1,y2,y3,nx1,nx2,nx3,ny1,ny2,ny3;             int xt,yt;              initwindow(1200,600);    ...

Tuesday, December 19, 2017

C++ program to draw a circle and ellipse in a single window (using graphics.h)

#include <graphics.h> #include <iostream> #include <conio.h> using namespace std; void circle(); void ellipse(); void plotpoints(int,int,int,int); int main(){ int gdriver = DETECT, gmode; initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi"); circle(); ellipse(); getch(); closegraph(); return 0; } void circle() {     int x,y,p,xc,yc,r;  ...

Monday, December 18, 2017

C++ program to draw an ellipse using Mid-point algorithm (using graphics.h)

#include<math.h> #include <graphics.h> #include <iostream> #include <conio.h> using namespace std; void plotpoints(int,int,int,int); int main(){ int xc,yc,x,y,p,rx,ry; int gdriver = DETECT, gmode; initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi"); cout<<"Enter co-ordinate for centre of ellipse:"; cin>>xc>>yc; cout<<"Enter the value of rx and ry of ellipse: "; cin>>rx>>ry; x=0; y=ry; p=ry*ry-ry*rx*rx+(1/4)*rx*rx; while((2*ry*ry*x)<(2*rx*rx*y)) {  ...

C++ program to draw a circle using Mid-point algorithm (using graphics.h)

#include <graphics.h> #include <iostream> #include <conio.h> using namespace std; int main(){ int xc,yc,x,y,p,r; int gdriver = DETECT, gmode; initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi"); cout<<"Enter co-ordinate for centre of circle:"; cin>>xc>>yc; cout<<"Enter radius of circle: "; cin>>r; x = 0; y = r; p = 1-r; while(x<=y){ if(p<0){ x=x+1; y=y+0; p=p+2*x +1; } else{ x=x+1; y=y-1; p=p+2*x-2*y+1; } putpixel(xc+x,yc+y,WHITE); putpixel(xc+y,yc+x,WHITE); putpixel(xc+x,yc-y,WHITE); putpixel(xc+y,yc-x,WHITE); putpixel(xc-x,yc-y,WHITE); putpixel(xc-y,yc-x,WHITE); putpixel(xc-x,yc+y,WHITE); putpixel(xc-y,yc+x,WHITE); delay(100); } getch(); closegraph(); return...

C++ program to draw a line using Bresenham's algorithm (using graphics.h)

#include<iostream> #include<graphics.h> using namespace std; void drawline(int,int,int,int); int main(){     int gdriver=DETECT, gmode, x1, y1, x2, y2;     initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");     cout<<"Enter co-ordinates of start point: ";     cin>>x1>>y1;     cout<<"Enter co-ordinates of end point: ";     cin>>x2>>y2;  ...

C++ Program for drawing line using DAA algorithm (using graphics.h)

#include <graphics.h> #include <iostream> #include <math.h> using namespace std; int main( ) {     float x,y,x1,y1,x2,y2,dx,dy,step;     int i,gd=DETECT,gm;     initgraph(&gd,&gm,"c:\\turboc3\\bgi");     cout<<"Enter the value of x1 and y1 : ";     cin>>x1>>y1;     cout<<"Enter the value of x2 and y2: ";     cin>>x2>>y2;  ...

Wednesday, December 13, 2017

FLAG OF NEPAL MADE IN OPENGL

Click here to download the source cod...