SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
CHHATTISGARH SWAMI VIVEKANAND TECHNICAL UNIVERSITY,
BHILAI (C.G.)
Semester – VI Branch – Computer Science And
Engineering
Subject: Computer Graphics Lab Code – 322622 (22)
Total Practical Periods – 40
Total Marks in end semester examination – 40
List of Experiments:
1. Write a program to draw the line using DDA algorithm.
2. Write a program to draw the line using Bresenham’s algorithm.
3. Write a program to draw circle using Bresenham’s algorithm.
4. Write a program to draw circle using mid-point algorithm.
5. Write a program to demonstrate draw ellipse using midpoint algorithm.
6. Write a program Rotation of Triangle.
7. Write a program Translation of Line.
8. Write a program to perform scaling of line.
9. Write a program shearing of Rectangle.
10. Write a program to implement boundary –fill algorithm.
11. Write a program to implement flood –fill algorithm.
12. Write a program to implement Bezier curve using four control points.
13. Write a program to implement CohenSutherland line clipping algorithm.
14. Write a program to implement Liang Barsky line clipping algorithm.
15. Write a program to implement face of a cartoon.
Book Reference:-
1. Computer Graphics & Multimedia- G. S. Baluja -Dhanpat Rai & CO.
2. Computer Graphics Donald Hearn & M Pauline Baker-Pearson Pvt.Ltd
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-1
1. Write a program to draw the line using DDA algorithm.
Digital Differential Analyzer (DDA) is used for linear interpolation of variables over an
interval between start and end point of a line. Simplest implementation the DDA
algorithm interpolates values in interval [(xstart, ystart), (xend, yend)] by computing for
each xi the equations xi = xi−1+1, yi = yi−1 + Δy/Δx,
Where Δx = xend − xstart and Δy = yend − ystart.
CODING:
#include <graphics.h>/* include the necessary header files*/
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void draw(int xa,int ya,int xb,int yb);
void main()
{
int xa,ya,xb,yb;
clrscr();
printf("Line DDA algorithm");
printf("n Enter the value of xa, ya:");
scanf("%d%d",&xa,&ya);
printf("n Enter the value of xb, yb:");
scanf("%d%d",&xb,&yb);
draw(xa,ya,xb,yb);
}
void draw(int xa,int ya,int xb,int yb)
{
int xin,yin,x,y,dx,dy,steps,k; /* request auto detection */
int gdriver=DETECT,gmode,errorcode; /* initialize graphics and local variables */
initgraph(&gdriver,&gmode, "c:tcbgi") /* read result of initialization */
errorcode=graphresult(); /* an error occurred */
if (errorcode!=grOk)
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
dx=xb-xa;
dy=yb-ya;
if(abs(dx)>abs(dy)) /* if the condition is satisfied */
{ /* calculate the value of the condition variable*/
steps=abs(dx);
}
else
{
steps=abs(dy);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
xin=dx/steps;
yin=dy/steps;
x=xa;
y=ya;
putpixel(x,y,1); /* draw the first pixel for the line*/
for(k=1;k<=steps;k++) /* for each value of the condition variable, */
{
x=x+xin; /* calculate the values of (x,y) and draw the pixel*/
y=y+yin;
putpixel(x,y,1);
} /* clean up */
getch();
closegraph();
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-2
2. Write a program to draw the line using Bresenham’s algorithm.
The Bresenham line algorithm is an algorithm which determines which points in an n-
dimensional raster should be plotted in order to form a close approximation to a straight
line between two given points. The endpoints of the line are the pixels at (x0, y0) and (x1,
y1), where the first coordinate of the pair is the column and the second is the row.
CODING:
#include <graphics.h>/* include the necessary header files*/
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void draw(int xa, int ya, int xb, int yb);
void main()
{
int xa, ya, xb, yb;
clrscr();
printf("Bresenhnams algorithm"); /* get the coordinates of the line*/
printf("n Enter the value of xa, ya:");
scanf("%d%d",&xa,&ya);
printf("n Enter the value of xb, yb:");
scanf("%d%d",&xb,&yb);
draw(xa,ya,xb,yb);
}
void draw(int xa, int ya, int xb, int yb)
{
int x,y,dx,dy,xend,p; /* request auto detection */
int gdriver=DETECT,gmode,errorcode; /* initialize graphics and local variables */
initgraph(&gdriver,&gmode,"c:tcbgi"); /* read result of initialization */
errorcode=graphresult(); /* an error occurred */
if(errorcode!=grOk)
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
dx=xb-xa;
dy=yb-ya;
p=2*dy-dx; /* calculate the value of the condition variable*/
if(xa>xb) /* depending on the position of the coordinates*/
{
x=xb; /* assign the values for (x,y)*/
y=yb;
xend=xa;
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
else if(xb>xa)
{
x=xa;
y=ya;
xend=xb;
}
putpixel(x,y,1); /* draw the pixel on the screen*/
while(x<xend) /* depending on the control condition draw the pixels*/
{
x=x+1;
if(p<0)
{
p=p+2*dy;
}
else
{
y=y+1;
p=p+2*dy;
}
putpixel(x,y,1);
} /* clean up */
getch();
closegraph();
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-3
3. Write a program to draw circle using mid-point algorithm.
The MidPoint Circle Algorithm is an algorithm used to determine the points needed for
drawing a circle. The algorithm is a variant of Bresenham's line algorithm, and is thus
sometimes known as Bresenham's circle algorithm. Which starts accordingly with the
circle equation x2 + y2 = r2. And with the center of the circle is located at (0, 0)
CODING:
#include<stdio.h>/* include the necessary header files*/
#include<conio.h>
#include<math.h>
#include<graphics.h>
main()
{
int gd=DETECT,gin;
int xcenter,ycenter,radius;
int p,x,y,twox,twoy; /*request auto detect*/
initgraph(&gd,&gin,"C:tcbgi");
x=0;
printf("nEnter the radius value:"); /* get the value of the radius and center values*/
scanf("%d",&radius);
printf("Enter the center values:");
scanf("%d %d",&xcenter,&ycenter);
plotpoints(xcenter,ycenter,x,y); /* call the plotpoints function*/
y=radius;
p=1-radius;
twox=2*x;
twoy=2*y;
printf("nptxtyt2xt2yn");
printf("n%dt%dt%dt%dt%dn",p,x,y,twox,twoy);
while(x<y) /* in the conditional loop compute the value of the x and y values*/
{
if(p<0)
x=x+1;
else
{
x=x+1;
y=y-1;
}
if(p<0)
p=p+2*x+1;
else
p=p+2*(x-y)+1;
twox=2*x;
twoy=2*y;
printf("n%dt%dt%dt%dt%dn",p,x,y,twox,twoy);
plotpoints(xcenter,ycenter,x,y);
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
}
getch();
return 0;
}
int plotpoints(int xcenter, int ycenter,int x,int y) /* plot the points of the circle as per
the procedure*/
{
putpixel(xcenter+x,ycenter+y,1);
putpixel(xcenter-x,ycenter+y,1);
putpixel(xcenter+x,ycenter-y,1);
putpixel(xcenter-x,ycenter-y,1);
putpixel(xcenter+y,ycenter+x,1);
putpixel(xcenter-y,ycenter+x,1);
putpixel(xcenter+y,ycenter-x,1);
putpixel(xcenter-y,ycenter-x,1);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-4
4. Write a program to draw ellipse using mid-point algorithm.
The Midpoint Ellipse Algorithm is a method for drawing ellipses in computer graphics
this method is modified from Bresenham’s which starts accordingly with the ellipse
equation b2x2 + a2y2 – a2b2 = 0 where a is the horizontal radius and b is the vertical
radius
CODING:
#include<stdio.h>/* include the necessary header files*/
#include<conio.h>
#include<graphics.h>
include<math.h>
#include<stdlib.h>
void plotpoints(int,int,int,int);
void main()
{
int gd=DETECT,gm;
int xcenter,ycenter,rx,ry;
int p,x,y,px,py,rx1,ry1,rx2,ry2;
initgraph(&gd,&gm,"C:TCBGI"); /* request auto detect*/
printf("n Enter the radius :"); /* get the radius and the center values*/
scanf("%d %d",&rx,&ry);
printf("n Enter the xcenter and ycenter values :");
scanf("%d %d",&xcenter,&ycenter);
ry1=ry*ry;
rx1=rx*rx;
ry2=2*ry1;
rx2=2*rx1;
/* Region 1 */
x=0;
y=ry;
plotpoints(xcenter,ycenter,x,y); /* for the first region calculate the condition
parameter*/
p=(ry1-rx1*ry+(0.25*rx1));
px=0;
py=rx2*y;
printf("nxtytptpxtpyn");
printf("n%dt%dt%dt%dt%d",x,y,p,px,py);
while(px<py) /* if this condition is true, compute values of x and y*/
{
x=x+1;
px=px+ry2;
if(p>=0)
{
y=y-1;
py=py-rx2;
p=p+ry1+px-py;
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
}
else
p=p+ry1+px;
plotpoints(xcenter,ycenter,x,y); /* call the plotpoints function*/
printf("n%dt%dt%dt%dt%d",x,y,p,px,py);
}
/* Region 2 */
printf("n%dt%dt%dt%dt%d",x,y,p,px,py);
printf("nnRegion 2n");
printf("nxtytptpxtpyn"); /* for region 2 recalculate the condition variables*/
p=(ry1*(x+0.5)*(x+0.5)+rx1*(y-1)*(y-1)-rx1*ry1);
while(y>0)
{
y=y-1;
py=py-rx2;
if(p<=0)
{
x=x+1;
px=px+ry2;
}
if(p>0)
p=p+rx1-py;
else
p=p+rx1-py+px;
plotpoints(xcenter,ycenter,x,y); /* draw the pixels for region 2*/
printf("n%dt%dt%dt%dt%d",x,y,p,px,py);
}
getch();
closegraph();
}
void plotpoints(int xcenter,int ycenter,int x,int y) /* plot the points of the circle as per
the procedure*/
{
putpixel(xcenter+x,ycenter+y,6);
putpixel(xcenter-x,ycenter+y,6);
putpixel(xcenter+x,ycenter-y,6);
putpixel(xcenter-x,ycenter-y,6);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-5
5. Write a program Rotation of Triangle.
A transformation is any operation on a point in space (x, y) that maps the point's
coordinates into a new set of coordinates (x1, y1).The Two Dimensional transformations
has five operations such as Translation, Rotation, Reflection, Scaling and Shearing.
CODING:
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
int x1,x2,x3,y1,y2,y3,t,tx,sx,sy,shx,shy,ch;
float rx1,rx2,rx3,ry1,ry2,ry3;
float ang,theta;
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode,"C:TCBGI"); /* request for auto detection*/
errorcode = graphresult();
if(errorcode != grOk) /* if error occours*/
{
printf("Graphics error: %sn", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
else
{
do{
printf("n1.Translationn2.Reflectionn3.Rotationn4.Scalingn5.Shearingn");
printf("nEnter Your choice"); /* get the choice from the user*/
scanf("%d",&ch);
switch(ch)
{
printf("n Enter all coordinates values :");
scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
printf("n Before Rotation "); /* get the original coordinates*/
line(x1,y1,x2,y2);
line(rx2,ry2,rx3,ry3);
line(rx3,ry3,rx1,ry1);
}
getch();
closegraph(); /* close the graph*/
return 0;
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-6
6.Write a program to implement boundary –fill algorithm
include<graphics.h>
#include<dos.h>
void fill_right(int x,int y);
void fill_left(int x,int y);
void main()
{
int gd=DETECT,gm,x,y,n,i;
clrscr();
initgraph(&gd,&gm,"c:turboc3bgi");
printf("*** Boundary Fill algorithm ***");
line (50,50,200,50);
line (200,50,200,300);
line (200,300,50,300);
line (50,300,50,50);
x=100; y=100;
fill_right(x,y);
fill_left(x-1,y);
getch();
}
void fill_right(int x,int y)
{
{
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED)
{
putpixel(x,y,RED);
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
fill_right(++x,y); x=x-1;
fill_right(x,y-1);
fill_right(x,y+1);
}
delay(1);
}
void fill_left(int x,int y)
{
if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED))
{
putpixel(x,y,RED);
fill_left(--x,y); x=x+1;
fill_left(x,y-1);
fill_left(x,y+1);
}
delay(1);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-7
7. Write a program to implement boundary –fill algorithm.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void boundfill(int xc,int yc,int r,int b)
{
int cur;
cur=getpixel(xc,yc);
if(cur!=b && cur!=r)
{
putpixel(xc,yc,r);
delay(1);
boundfill(xc+1,yc,r,b);
boundfill(xc-1,yc,r,b);
boundfill(xc,yc+1,r,b);
boundfill(xc,yc-1,r,b);
}
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"..bgi");
rectangle(100,100,300,300);
boundfill(105,105,4,WHITE);
getch();
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
closegraph();
}
getch();
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-8
8. Write a program to implement Bezier curve using four control points.
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <math.h>
void bezier (int x[4], int y[4])
{
int gd = DETECT, gm; int i;
double t;
initgraph (&gd, &gm, "..bgi");
for (t = 0.0; t < 1.0; t += 0.0005)
{
double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] + 3 * pow (t, 2) * (1-t) * x[2]
+ pow (t, 3) * x[3];
double yt = pow (1-t, 3) * y[0] + 3 * t * pow (1-t, 2) * y[1] + 3 * pow (t, 2) * (1-t)
* y[2] + pow (t, 3) * y[3];
putpixel (xt, yt, WHITE);
}
for (i=0; i<4; i++)
putpixel (x[i], y[i], YELLOW);
getch();
closegraph();
return;
}
void main()
{
int x[4], y[4]; int i;
printf ("Enter the x- and y-coordinates of the four control points.n");
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
for (i=0; i<4; i++) scanf ("%d%d", &x[i], &y[i]); bezier (x, y);
}
closegraph();
}
getch();
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-9
9. Write a program to implement CohenSutherland line clipping algorithm.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void clip(float,float,float);
int i,j=0,n;
int rx1,rx2,ry1,ry2;
float x1[8],y1[8];
void main()
{
int gd=DETECT,gm;
int i,n;
float x[8],y[8],m;
clrscr();
initgraph(&gd,&gm,"");
printf("coordinates for rectangle : ");
scanf("%d%d%d%d",&rx1,&ry1,&rx2,&ry2);
printf("no. of sides for polygon : ");
scanf("%d",&n);
printf("coordinates : ");
for(i=0;i<n;i++)
{
scanf("%f%f",&x[i],&y[i]);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
cleardevice();
outtextxy(10,10,"Before clipping");
outtextxy(10,470,"Press any key....");
rectangle(rx1,ry1,rx2,ry2);
for(i=0;i<n-1;i++)
line(x[i],y[i],x[i+1],y[i+1]);
line(x[i],y[i],x[0],y[0]);
getch();
cleardevice();
for(i=0;i<n-1;i++)
{
m=(y[i+1]-y[i])/(x[i+1]-x[i]);
clip(x[i],y[i],m);
}
clip(x[0],y[0],m);
outtextxy(10,10,"After clipping");
outtextxy(10,470,"Press any key....");
rectangle(rx1,ry1,rx2,ry2);
for(i=0;i<j-1;i++)
line(x1[i],y1[i],x1[i+1],y1[i+1]);
getch();
}
void clip(float e,float f,float m)
{
while(e<rx1 e>rx2 f<ry1 f>ry2)
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
{
if(e<rx1)
{
f+=m*(rx1-e);
e=rx1;
}
else if(e>rx2)
{
f+=m*(rx2-e);
e=rx1;
}
if(f<ry1)
{
e+=(ry1-f)/m;
f=ry1;
}
else if(f>ry2)
{
e+=(ry2-f)/m;
f=ry2;
}
x1[j]=e;
y1[j]=f;
j++;
}
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-10
10. Write a program to implement Liang Barsky line clipping algorithm.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
Void main
{
float x1,y1,x2,y2,xmin,xmax,ymin,ymax,dx,dy;
float p[4],q[4],r[4];
float max,min,u1,u2;
float xi,xii,yi,yii;
int gd,gm,i;
gd=DETECT;
initgraph(&gd,&gm,"c:tcbgi");
clrscr();
printf("n enter the line co-ordinates");
printf("n enter 1st x=");
scanf("%f",&x1);
printf("t 1st y=");
scanf("%f",&y1);
printf("n enter 2nd x=");
scanf("%f",&x2);
printf("t 2nd y=");
scanf("%f",&y2);
printf("n enter window boundry");
printf("n xmin=");
scanf("%f",&xmin);
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
printf("n ymin=");
scanf("%f",&ymin);
printf("n xmax=");
scanf("%f",&xmax);
printf("n ymax=");
scanf("%f",&ymax)
dx=x2-x1;
dy=y2-y1;
cleardevice();
line(x1,y1,x2,y2);
rectangle(xmin,ymin,xmax,ymax);
p[0]=-dx;
q[0]=x1-xmin;
p[1]=dx;
q[1]=xmax-x1;
p[2]=-dy;
p[2]=-dy;
q[2]=y1-ymin;
p[3]=dy;
q[3]=ymax-y1;
for(i=0;i<4;i++)
{
if(p[i]==0 && q[i]<0)
{
printf("Line is outside the boundry,it is not a clipping candidaten");
getch();
exit(0);
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
}
for(i=0;i<4;i++)
{
r[i]=q[i]/p[i];
printf("n r[%d]=%f",i,r[i]);
}
max=0;min=1;
for(i=0;i<4;i++)
if(p[i]<0)
{
if(r[i]>max)
max=r[i];
}
else
{
if(r[i]<min)
min=r[i];
}
u1=max;
u2=min;
printf("n u1=%f",u1);
printf("n u2=%f",u2);
if(u1>u2)
{
printf("n line is completely outside");
getch();
exit(0);
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
}
xi=x1+(u1*dx);
yi=y1+(u1*dy);
xii=x1+(u2*dx);
yii=y1+(u2*dy);
rectangle (xmin, ymin, xmax, ymax);
sector(5);
line(xi,yi,xii,yii);
getch();
closegraph();
}
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
EXPERIMENT-11
11. Write a program to implement face of a cartoon.
# include <graphics.h>
# include<conio.h>
#include <stdlib.h>
main()
{
int gd= DETECT, gm,area, temp1, temp2, left=25, top=75;
void*p;
initgraph(&gd, &gm,”C:TCBGI”);
Setcolor(YELLOW);
Circle(50, 100,25);
Sefillstyle(SOLID__FILL,YELLOW);
floodfill(50,100, YELLOW);
Setcolor(BLACK);
Sefillstyle(SOLID__FILL,BLACK);
fillellipse(44, 85, 2, 6);
fillellipse(56, 85, 2, 6);
ellipse(50, 100, 205, 335, 20,9);
ellipse(50, 100, 205, 335, 20,10);
ellipse(50, 100, 205, 335, 20,11);
area= imagesize(left, top, left+ 50, top+50);
p= malloc(area);
setcolor(WHITE);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(155, 451, “Smiling Face Animation”);
setcolor(BLUE);
rectangle(0,0 , 639,449);
while(!kbhit())
{
Temp1= 1+ randam(588);
{
Temp1= 1+ randam(380);
{
Getimage(left, top, left+ 50, top+ 50);
putimage(left, top, p, XOR_PUT);
putimage(temp1, temp2, p, XOR_PUT);
delay(100);
left= temp1;
top = temp2;
Shri Rawatpura Sarkar Institute of Technology-II, New Raipur
CSE/6th
/CG Lab/PreparedbyToranLal Sahu
}
getch();
closegraph();
return();
}

Weitere ähnliche Inhalte

Was ist angesagt?

Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programmingKamal Acharya
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiionMuhammadHamza401
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphicsPartnered Health
 
ER(ENTITY-RELATIONSHIP) diagram(Game)
ER(ENTITY-RELATIONSHIP) diagram(Game)ER(ENTITY-RELATIONSHIP) diagram(Game)
ER(ENTITY-RELATIONSHIP) diagram(Game)Abhishek Panda
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displaysSomya Bagai
 
Applications of cg
Applications of cgApplications of cg
Applications of cgAnkit Garg
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsMohsin Azam
 
Computer Graphics - Output Primitive
Computer Graphics - Output PrimitiveComputer Graphics - Output Primitive
Computer Graphics - Output PrimitiveRupesh Mishra
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics SystemPrathimaBaliga
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 

Was ist angesagt? (20)

Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
Introduction to computer graphics
Introduction to computer graphicsIntroduction to computer graphics
Introduction to computer graphics
 
ER(ENTITY-RELATIONSHIP) diagram(Game)
ER(ENTITY-RELATIONSHIP) diagram(Game)ER(ENTITY-RELATIONSHIP) diagram(Game)
ER(ENTITY-RELATIONSHIP) diagram(Game)
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 
Random scan displays and raster scan displays
Random scan displays and raster scan displaysRandom scan displays and raster scan displays
Random scan displays and raster scan displays
 
Applications of cg
Applications of cgApplications of cg
Applications of cg
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer Graphics - Output Primitive
Computer Graphics - Output PrimitiveComputer Graphics - Output Primitive
Computer Graphics - Output Primitive
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Overview of Graphics System
Overview of Graphics SystemOverview of Graphics System
Overview of Graphics System
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Project report
Project reportProject report
Project report
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 

Andere mochten auch

Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics PracticalNeha Sharma
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneBhavesh Shah
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics ProgramesAbhishek Sharma
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics labPriya Goyal
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics fileaman1001
 
Company Profile - Compressed
Company Profile - CompressedCompany Profile - Compressed
Company Profile - CompressedSolly Moeng - APR
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Buşra Deniz, CSM
 
Computer applications in civil engineering lab
Computer applications in civil engineering labComputer applications in civil engineering lab
Computer applications in civil engineering labVivek Kumar Sinha
 
Computer hardware and simulation lab manual
Computer  hardware and simulation lab manualComputer  hardware and simulation lab manual
Computer hardware and simulation lab manualVivek Kumar Sinha
 
Softwareenggineering lab manual
Softwareenggineering lab manualSoftwareenggineering lab manual
Softwareenggineering lab manualVivek Kumar Sinha
 
Graphics User Interface Lab Manual
Graphics User Interface Lab ManualGraphics User Interface Lab Manual
Graphics User Interface Lab ManualVivek Kumar Sinha
 

Andere mochten auch (20)

Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics Programes
 
Basics of Computer graphics lab
Basics of Computer graphics labBasics of Computer graphics lab
Basics of Computer graphics lab
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics file
 
syed mohd naqi zaidi
syed mohd naqi zaidisyed mohd naqi zaidi
syed mohd naqi zaidi
 
Oracle Notes
Oracle NotesOracle Notes
Oracle Notes
 
Company Profile - Compressed
Company Profile - CompressedCompany Profile - Compressed
Company Profile - Compressed
 
Lab manual asp.net
Lab manual asp.netLab manual asp.net
Lab manual asp.net
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015
 
Cn lab manual
Cn lab manualCn lab manual
Cn lab manual
 
Teks ekposisi
Teks ekposisiTeks ekposisi
Teks ekposisi
 
Computer applications in civil engineering lab
Computer applications in civil engineering labComputer applications in civil engineering lab
Computer applications in civil engineering lab
 
Mech nacp lab
Mech nacp labMech nacp lab
Mech nacp lab
 
Computer hardware and simulation lab manual
Computer  hardware and simulation lab manualComputer  hardware and simulation lab manual
Computer hardware and simulation lab manual
 
Softwareenggineering lab manual
Softwareenggineering lab manualSoftwareenggineering lab manual
Softwareenggineering lab manual
 
Oops lab manual
Oops lab manualOops lab manual
Oops lab manual
 
Graphics User Interface Lab Manual
Graphics User Interface Lab ManualGraphics User Interface Lab Manual
Graphics User Interface Lab Manual
 
Java final lab
Java final labJava final lab
Java final lab
 

Ähnlich wie Graphics practical lab manual (20)

Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs file
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
 
week-3x
week-3xweek-3x
week-3x
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
C and Data Structures Lab Solutions
C and Data Structures Lab SolutionsC and Data Structures Lab Solutions
C and Data Structures Lab Solutions
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
 
Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
 
C programs
C programsC programs
C programs
 
C programs
C programsC programs
C programs
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C- Programming Assignment 4 solution
C- Programming Assignment 4 solutionC- Programming Assignment 4 solution
C- Programming Assignment 4 solution
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
week-8x
week-8xweek-8x
week-8x
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 

Mehr von Vivek Kumar Sinha (20)

Software engg unit 4
Software engg unit 4 Software engg unit 4
Software engg unit 4
 
Software engg unit 3
Software engg unit 3 Software engg unit 3
Software engg unit 3
 
Software engg unit 2
Software engg unit 2 Software engg unit 2
Software engg unit 2
 
Software engg unit 1
Software engg unit 1 Software engg unit 1
Software engg unit 1
 
Data structure
Data structureData structure
Data structure
 
Mathematics basics
Mathematics basicsMathematics basics
Mathematics basics
 
E commerce 5_units_notes
E commerce 5_units_notesE commerce 5_units_notes
E commerce 5_units_notes
 
B.ped
B.pedB.ped
B.ped
 
Subject distribution
Subject distributionSubject distribution
Subject distribution
 
Revision report final
Revision report finalRevision report final
Revision report final
 
Lession plan mis
Lession plan misLession plan mis
Lession plan mis
 
Lession plan dmw
Lession plan dmwLession plan dmw
Lession plan dmw
 
Faculty planning
Faculty planningFaculty planning
Faculty planning
 
Final presentation on computer network
Final presentation on computer networkFinal presentation on computer network
Final presentation on computer network
 
Np syllabus summary
Np syllabus summaryNp syllabus summary
Np syllabus summary
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Induction program 2017
Induction program 2017Induction program 2017
Induction program 2017
 
Vivek
VivekVivek
Vivek
 
E magzine et&amp;t
E magzine et&amp;tE magzine et&amp;t
E magzine et&amp;t
 
Mechanical engineering department (1)
Mechanical engineering department (1)Mechanical engineering department (1)
Mechanical engineering department (1)
 

Kürzlich hochgeladen

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 

Kürzlich hochgeladen (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 

Graphics practical lab manual

  • 1. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu CHHATTISGARH SWAMI VIVEKANAND TECHNICAL UNIVERSITY, BHILAI (C.G.) Semester – VI Branch – Computer Science And Engineering Subject: Computer Graphics Lab Code – 322622 (22) Total Practical Periods – 40 Total Marks in end semester examination – 40 List of Experiments: 1. Write a program to draw the line using DDA algorithm. 2. Write a program to draw the line using Bresenham’s algorithm. 3. Write a program to draw circle using Bresenham’s algorithm. 4. Write a program to draw circle using mid-point algorithm. 5. Write a program to demonstrate draw ellipse using midpoint algorithm. 6. Write a program Rotation of Triangle. 7. Write a program Translation of Line. 8. Write a program to perform scaling of line. 9. Write a program shearing of Rectangle. 10. Write a program to implement boundary –fill algorithm. 11. Write a program to implement flood –fill algorithm. 12. Write a program to implement Bezier curve using four control points. 13. Write a program to implement CohenSutherland line clipping algorithm. 14. Write a program to implement Liang Barsky line clipping algorithm. 15. Write a program to implement face of a cartoon. Book Reference:- 1. Computer Graphics & Multimedia- G. S. Baluja -Dhanpat Rai & CO. 2. Computer Graphics Donald Hearn & M Pauline Baker-Pearson Pvt.Ltd
  • 2. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-1 1. Write a program to draw the line using DDA algorithm. Digital Differential Analyzer (DDA) is used for linear interpolation of variables over an interval between start and end point of a line. Simplest implementation the DDA algorithm interpolates values in interval [(xstart, ystart), (xend, yend)] by computing for each xi the equations xi = xi−1+1, yi = yi−1 + Δy/Δx, Where Δx = xend − xstart and Δy = yend − ystart. CODING: #include <graphics.h>/* include the necessary header files*/ #include <stdlib.h> #include <stdio.h> #include <conio.h> void draw(int xa,int ya,int xb,int yb); void main() { int xa,ya,xb,yb; clrscr(); printf("Line DDA algorithm"); printf("n Enter the value of xa, ya:"); scanf("%d%d",&xa,&ya); printf("n Enter the value of xb, yb:"); scanf("%d%d",&xb,&yb); draw(xa,ya,xb,yb); } void draw(int xa,int ya,int xb,int yb) { int xin,yin,x,y,dx,dy,steps,k; /* request auto detection */ int gdriver=DETECT,gmode,errorcode; /* initialize graphics and local variables */ initgraph(&gdriver,&gmode, "c:tcbgi") /* read result of initialization */ errorcode=graphresult(); /* an error occurred */ if (errorcode!=grOk) { printf("Graphics error: %sn", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } dx=xb-xa; dy=yb-ya; if(abs(dx)>abs(dy)) /* if the condition is satisfied */ { /* calculate the value of the condition variable*/ steps=abs(dx); } else { steps=abs(dy); }
  • 3. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu xin=dx/steps; yin=dy/steps; x=xa; y=ya; putpixel(x,y,1); /* draw the first pixel for the line*/ for(k=1;k<=steps;k++) /* for each value of the condition variable, */ { x=x+xin; /* calculate the values of (x,y) and draw the pixel*/ y=y+yin; putpixel(x,y,1); } /* clean up */ getch(); closegraph(); }
  • 4. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-2 2. Write a program to draw the line using Bresenham’s algorithm. The Bresenham line algorithm is an algorithm which determines which points in an n- dimensional raster should be plotted in order to form a close approximation to a straight line between two given points. The endpoints of the line are the pixels at (x0, y0) and (x1, y1), where the first coordinate of the pair is the column and the second is the row. CODING: #include <graphics.h>/* include the necessary header files*/ #include <stdlib.h> #include <stdio.h> #include <conio.h> void draw(int xa, int ya, int xb, int yb); void main() { int xa, ya, xb, yb; clrscr(); printf("Bresenhnams algorithm"); /* get the coordinates of the line*/ printf("n Enter the value of xa, ya:"); scanf("%d%d",&xa,&ya); printf("n Enter the value of xb, yb:"); scanf("%d%d",&xb,&yb); draw(xa,ya,xb,yb); } void draw(int xa, int ya, int xb, int yb) { int x,y,dx,dy,xend,p; /* request auto detection */ int gdriver=DETECT,gmode,errorcode; /* initialize graphics and local variables */ initgraph(&gdriver,&gmode,"c:tcbgi"); /* read result of initialization */ errorcode=graphresult(); /* an error occurred */ if(errorcode!=grOk) { printf("Graphics error: %sn", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } dx=xb-xa; dy=yb-ya; p=2*dy-dx; /* calculate the value of the condition variable*/ if(xa>xb) /* depending on the position of the coordinates*/ { x=xb; /* assign the values for (x,y)*/ y=yb; xend=xa; }
  • 5. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu else if(xb>xa) { x=xa; y=ya; xend=xb; } putpixel(x,y,1); /* draw the pixel on the screen*/ while(x<xend) /* depending on the control condition draw the pixels*/ { x=x+1; if(p<0) { p=p+2*dy; } else { y=y+1; p=p+2*dy; } putpixel(x,y,1); } /* clean up */ getch(); closegraph(); }
  • 6. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-3 3. Write a program to draw circle using mid-point algorithm. The MidPoint Circle Algorithm is an algorithm used to determine the points needed for drawing a circle. The algorithm is a variant of Bresenham's line algorithm, and is thus sometimes known as Bresenham's circle algorithm. Which starts accordingly with the circle equation x2 + y2 = r2. And with the center of the circle is located at (0, 0) CODING: #include<stdio.h>/* include the necessary header files*/ #include<conio.h> #include<math.h> #include<graphics.h> main() { int gd=DETECT,gin; int xcenter,ycenter,radius; int p,x,y,twox,twoy; /*request auto detect*/ initgraph(&gd,&gin,"C:tcbgi"); x=0; printf("nEnter the radius value:"); /* get the value of the radius and center values*/ scanf("%d",&radius); printf("Enter the center values:"); scanf("%d %d",&xcenter,&ycenter); plotpoints(xcenter,ycenter,x,y); /* call the plotpoints function*/ y=radius; p=1-radius; twox=2*x; twoy=2*y; printf("nptxtyt2xt2yn"); printf("n%dt%dt%dt%dt%dn",p,x,y,twox,twoy); while(x<y) /* in the conditional loop compute the value of the x and y values*/ { if(p<0) x=x+1; else { x=x+1; y=y-1; } if(p<0) p=p+2*x+1; else p=p+2*(x-y)+1; twox=2*x; twoy=2*y; printf("n%dt%dt%dt%dt%dn",p,x,y,twox,twoy); plotpoints(xcenter,ycenter,x,y);
  • 7. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu } getch(); return 0; } int plotpoints(int xcenter, int ycenter,int x,int y) /* plot the points of the circle as per the procedure*/ { putpixel(xcenter+x,ycenter+y,1); putpixel(xcenter-x,ycenter+y,1); putpixel(xcenter+x,ycenter-y,1); putpixel(xcenter-x,ycenter-y,1); putpixel(xcenter+y,ycenter+x,1); putpixel(xcenter-y,ycenter+x,1); putpixel(xcenter+y,ycenter-x,1); putpixel(xcenter-y,ycenter-x,1); }
  • 8. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-4 4. Write a program to draw ellipse using mid-point algorithm. The Midpoint Ellipse Algorithm is a method for drawing ellipses in computer graphics this method is modified from Bresenham’s which starts accordingly with the ellipse equation b2x2 + a2y2 – a2b2 = 0 where a is the horizontal radius and b is the vertical radius CODING: #include<stdio.h>/* include the necessary header files*/ #include<conio.h> #include<graphics.h> include<math.h> #include<stdlib.h> void plotpoints(int,int,int,int); void main() { int gd=DETECT,gm; int xcenter,ycenter,rx,ry; int p,x,y,px,py,rx1,ry1,rx2,ry2; initgraph(&gd,&gm,"C:TCBGI"); /* request auto detect*/ printf("n Enter the radius :"); /* get the radius and the center values*/ scanf("%d %d",&rx,&ry); printf("n Enter the xcenter and ycenter values :"); scanf("%d %d",&xcenter,&ycenter); ry1=ry*ry; rx1=rx*rx; ry2=2*ry1; rx2=2*rx1; /* Region 1 */ x=0; y=ry; plotpoints(xcenter,ycenter,x,y); /* for the first region calculate the condition parameter*/ p=(ry1-rx1*ry+(0.25*rx1)); px=0; py=rx2*y; printf("nxtytptpxtpyn"); printf("n%dt%dt%dt%dt%d",x,y,p,px,py); while(px<py) /* if this condition is true, compute values of x and y*/ { x=x+1; px=px+ry2; if(p>=0) { y=y-1; py=py-rx2; p=p+ry1+px-py;
  • 9. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu } else p=p+ry1+px; plotpoints(xcenter,ycenter,x,y); /* call the plotpoints function*/ printf("n%dt%dt%dt%dt%d",x,y,p,px,py); } /* Region 2 */ printf("n%dt%dt%dt%dt%d",x,y,p,px,py); printf("nnRegion 2n"); printf("nxtytptpxtpyn"); /* for region 2 recalculate the condition variables*/ p=(ry1*(x+0.5)*(x+0.5)+rx1*(y-1)*(y-1)-rx1*ry1); while(y>0) { y=y-1; py=py-rx2; if(p<=0) { x=x+1; px=px+ry2; } if(p>0) p=p+rx1-py; else p=p+rx1-py+px; plotpoints(xcenter,ycenter,x,y); /* draw the pixels for region 2*/ printf("n%dt%dt%dt%dt%d",x,y,p,px,py); } getch(); closegraph(); } void plotpoints(int xcenter,int ycenter,int x,int y) /* plot the points of the circle as per the procedure*/ { putpixel(xcenter+x,ycenter+y,6); putpixel(xcenter-x,ycenter+y,6); putpixel(xcenter+x,ycenter-y,6); putpixel(xcenter-x,ycenter-y,6); }
  • 10. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-5 5. Write a program Rotation of Triangle. A transformation is any operation on a point in space (x, y) that maps the point's coordinates into a new set of coordinates (x1, y1).The Two Dimensional transformations has five operations such as Translation, Rotation, Reflection, Scaling and Shearing. CODING: #include<graphics.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> int x1,x2,x3,y1,y2,y3,t,tx,sx,sy,shx,shy,ch; float rx1,rx2,rx3,ry1,ry2,ry3; float ang,theta; int main(void) { int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode,"C:TCBGI"); /* request for auto detection*/ errorcode = graphresult(); if(errorcode != grOk) /* if error occours*/ { printf("Graphics error: %sn", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } else { do{ printf("n1.Translationn2.Reflectionn3.Rotationn4.Scalingn5.Shearingn"); printf("nEnter Your choice"); /* get the choice from the user*/ scanf("%d",&ch); switch(ch) { printf("n Enter all coordinates values :"); scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3); printf("n Before Rotation "); /* get the original coordinates*/ line(x1,y1,x2,y2); line(rx2,ry2,rx3,ry3); line(rx3,ry3,rx1,ry1); } getch(); closegraph(); /* close the graph*/ return 0; }
  • 11. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-6 6.Write a program to implement boundary –fill algorithm include<graphics.h> #include<dos.h> void fill_right(int x,int y); void fill_left(int x,int y); void main() { int gd=DETECT,gm,x,y,n,i; clrscr(); initgraph(&gd,&gm,"c:turboc3bgi"); printf("*** Boundary Fill algorithm ***"); line (50,50,200,50); line (200,50,200,300); line (200,300,50,300); line (50,300,50,50); x=100; y=100; fill_right(x,y); fill_left(x-1,y); getch(); } void fill_right(int x,int y) { { if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED) { putpixel(x,y,RED);
  • 12. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu fill_right(++x,y); x=x-1; fill_right(x,y-1); fill_right(x,y+1); } delay(1); } void fill_left(int x,int y) { if((getpixel(x,y) != WHITE)&&(getpixel(x,y) != RED)) { putpixel(x,y,RED); fill_left(--x,y); x=x+1; fill_left(x,y-1); fill_left(x,y+1); } delay(1); }
  • 13. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-7 7. Write a program to implement boundary –fill algorithm. #include<stdio.h> #include<conio.h> #include<graphics.h> void boundfill(int xc,int yc,int r,int b) { int cur; cur=getpixel(xc,yc); if(cur!=b && cur!=r) { putpixel(xc,yc,r); delay(1); boundfill(xc+1,yc,r,b); boundfill(xc-1,yc,r,b); boundfill(xc,yc+1,r,b); boundfill(xc,yc-1,r,b); } } void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"..bgi"); rectangle(100,100,300,300); boundfill(105,105,4,WHITE); getch();
  • 14. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu closegraph(); } getch(); }
  • 15. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-8 8. Write a program to implement Bezier curve using four control points. #include <stdio.h> #include <stdlib.h> #include <graphics.h> #include <math.h> void bezier (int x[4], int y[4]) { int gd = DETECT, gm; int i; double t; initgraph (&gd, &gm, "..bgi"); for (t = 0.0; t < 1.0; t += 0.0005) { double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] + 3 * pow (t, 2) * (1-t) * x[2] + pow (t, 3) * x[3]; double yt = pow (1-t, 3) * y[0] + 3 * t * pow (1-t, 2) * y[1] + 3 * pow (t, 2) * (1-t) * y[2] + pow (t, 3) * y[3]; putpixel (xt, yt, WHITE); } for (i=0; i<4; i++) putpixel (x[i], y[i], YELLOW); getch(); closegraph(); return; } void main() { int x[4], y[4]; int i; printf ("Enter the x- and y-coordinates of the four control points.n");
  • 16. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu for (i=0; i<4; i++) scanf ("%d%d", &x[i], &y[i]); bezier (x, y); } closegraph(); } getch(); }
  • 17. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-9 9. Write a program to implement CohenSutherland line clipping algorithm. #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void clip(float,float,float); int i,j=0,n; int rx1,rx2,ry1,ry2; float x1[8],y1[8]; void main() { int gd=DETECT,gm; int i,n; float x[8],y[8],m; clrscr(); initgraph(&gd,&gm,""); printf("coordinates for rectangle : "); scanf("%d%d%d%d",&rx1,&ry1,&rx2,&ry2); printf("no. of sides for polygon : "); scanf("%d",&n); printf("coordinates : "); for(i=0;i<n;i++) { scanf("%f%f",&x[i],&y[i]); }
  • 18. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu cleardevice(); outtextxy(10,10,"Before clipping"); outtextxy(10,470,"Press any key...."); rectangle(rx1,ry1,rx2,ry2); for(i=0;i<n-1;i++) line(x[i],y[i],x[i+1],y[i+1]); line(x[i],y[i],x[0],y[0]); getch(); cleardevice(); for(i=0;i<n-1;i++) { m=(y[i+1]-y[i])/(x[i+1]-x[i]); clip(x[i],y[i],m); } clip(x[0],y[0],m); outtextxy(10,10,"After clipping"); outtextxy(10,470,"Press any key...."); rectangle(rx1,ry1,rx2,ry2); for(i=0;i<j-1;i++) line(x1[i],y1[i],x1[i+1],y1[i+1]); getch(); } void clip(float e,float f,float m) { while(e<rx1 e>rx2 f<ry1 f>ry2)
  • 19. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu { if(e<rx1) { f+=m*(rx1-e); e=rx1; } else if(e>rx2) { f+=m*(rx2-e); e=rx1; } if(f<ry1) { e+=(ry1-f)/m; f=ry1; } else if(f>ry2) { e+=(ry2-f)/m; f=ry2; } x1[j]=e; y1[j]=f; j++; } }
  • 20. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-10 10. Write a program to implement Liang Barsky line clipping algorithm. #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> Void main { float x1,y1,x2,y2,xmin,xmax,ymin,ymax,dx,dy; float p[4],q[4],r[4]; float max,min,u1,u2; float xi,xii,yi,yii; int gd,gm,i; gd=DETECT; initgraph(&gd,&gm,"c:tcbgi"); clrscr(); printf("n enter the line co-ordinates"); printf("n enter 1st x="); scanf("%f",&x1); printf("t 1st y="); scanf("%f",&y1); printf("n enter 2nd x="); scanf("%f",&x2); printf("t 2nd y="); scanf("%f",&y2); printf("n enter window boundry"); printf("n xmin="); scanf("%f",&xmin);
  • 21. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu printf("n ymin="); scanf("%f",&ymin); printf("n xmax="); scanf("%f",&xmax); printf("n ymax="); scanf("%f",&ymax) dx=x2-x1; dy=y2-y1; cleardevice(); line(x1,y1,x2,y2); rectangle(xmin,ymin,xmax,ymax); p[0]=-dx; q[0]=x1-xmin; p[1]=dx; q[1]=xmax-x1; p[2]=-dy; p[2]=-dy; q[2]=y1-ymin; p[3]=dy; q[3]=ymax-y1; for(i=0;i<4;i++) { if(p[i]==0 && q[i]<0) { printf("Line is outside the boundry,it is not a clipping candidaten"); getch(); exit(0); }
  • 22. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu } for(i=0;i<4;i++) { r[i]=q[i]/p[i]; printf("n r[%d]=%f",i,r[i]); } max=0;min=1; for(i=0;i<4;i++) if(p[i]<0) { if(r[i]>max) max=r[i]; } else { if(r[i]<min) min=r[i]; } u1=max; u2=min; printf("n u1=%f",u1); printf("n u2=%f",u2); if(u1>u2) { printf("n line is completely outside"); getch(); exit(0);
  • 23. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu } xi=x1+(u1*dx); yi=y1+(u1*dy); xii=x1+(u2*dx); yii=y1+(u2*dy); rectangle (xmin, ymin, xmax, ymax); sector(5); line(xi,yi,xii,yii); getch(); closegraph(); }
  • 24. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu EXPERIMENT-11 11. Write a program to implement face of a cartoon. # include <graphics.h> # include<conio.h> #include <stdlib.h> main() { int gd= DETECT, gm,area, temp1, temp2, left=25, top=75; void*p; initgraph(&gd, &gm,”C:TCBGI”); Setcolor(YELLOW); Circle(50, 100,25); Sefillstyle(SOLID__FILL,YELLOW); floodfill(50,100, YELLOW); Setcolor(BLACK); Sefillstyle(SOLID__FILL,BLACK); fillellipse(44, 85, 2, 6); fillellipse(56, 85, 2, 6); ellipse(50, 100, 205, 335, 20,9); ellipse(50, 100, 205, 335, 20,10); ellipse(50, 100, 205, 335, 20,11); area= imagesize(left, top, left+ 50, top+50); p= malloc(area); setcolor(WHITE); settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2); outtextxy(155, 451, “Smiling Face Animation”); setcolor(BLUE); rectangle(0,0 , 639,449); while(!kbhit()) { Temp1= 1+ randam(588); { Temp1= 1+ randam(380); { Getimage(left, top, left+ 50, top+ 50); putimage(left, top, p, XOR_PUT); putimage(temp1, temp2, p, XOR_PUT); delay(100); left= temp1; top = temp2;
  • 25. Shri Rawatpura Sarkar Institute of Technology-II, New Raipur CSE/6th /CG Lab/PreparedbyToranLal Sahu } getch(); closegraph(); return(); }