INDEX Lab Name : Computer Graphics & Multimedia Lab Lab Code : Name Reg No
: :
GRAPHICS LAB SL #.
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
LAB EXERCISES DDA LINE DRAWING ALGORITHM BRESENHAMS LINE DRAWING ALGORITHM MID POINT CIRCLE DRAWING ALGORITHM LINE STYLES FILL PATTERN STYLES SHAPES WHEEL ROTATION LINE CLIPPING 2D - TRANSFORMATION BAR CHART LINE CHART
DATE
SIGNATURE
Multimedia Lab SL #.
1. 2. 3. 4. 5.
LAB EXERCISES LOGO CREATION DISPLACEMENT EFFECT ANIMATION EFFECT MIRROR IMAGE MORPHING
Staff Name Staff Signature
: :
DATE
SIGNATURE
Exp No : Date : DDA LINE DRAWING ALGORITHM AIM:
To write a program to implement the DDA line drawing algorithm. ALGORITHM: • Get the coordinates of end points of line • Calculate dx and dy values • Compare the absolute values • Using setpixel function plot points in appropriate pixels
FLOWCHART:DDA LINE DRAWING ALGORITHM
Start
Initialize Graphics Mode
Enter the values of end points in xa,ya,xb,yb
dx=abs(xa-xb) dy =abs(ya-yb)
If (abs (dx) > abs(dy))
Step=dx
Step=dy
xl = dx/ step y1=dy/step x = xa y=ya
A
A
putpixel(x,y,1)
For(k=1;k <=step;k++)
x=x+x1 x= x+0.5 y=y+y1 y= y+0.5
putpixel(x,y,1)
Stop
PROGRAM: #include #include #include<stdio.h> #include<math.h> void drawline(int xl,int y1,int x2;int y2) { int dx,dy,steps,k; float xinc,yinc,x,y; int gdriver=DETECT,gmode,errorcode; initgraph(&gdriver,&gmode,""); dx=x2-x1 ; dy=y2-y1; if(abs(dx)>abs(dy)) steps=abs(dx); else steps=abs(dy); xinc=dx/steps; yinc=dy/steps, x=x1; y=y1; putpixel(x,y,3); for(k=1;k<steps;k++) { x+=xinc; y+=yinc; putpixel(x,y,3); } getch(); closegraph(); } void main() { int x1,y1,x2,y2; clrscr(); printf("Enter The 1st Coordinate"); scanf("%d %d",&x1,&y1); printf('Enter The 2nd Coordinate"); scanf("%d %d",&x2,&y2); drawline(x1,y1,x2,y2); }
OUTPUT
RESULT: Thus the program was executed successfully and the output was verified.
Exp No : Date : BRESENHAMS LINE DRAWING ALGORITHM AIM: To implement BRESENHAM line drawing algorithm using C.
ALGORITHM: •
Input the end points of the line , • Load the end points into the frame buffer and plot the first point • Calculate dx and dy,2dy-2dx • Calculate p0 = 2dy-dx • Calculate pk value and plot the next point
FLOWCHART : BRESENHAMS Start
Initailize Graphics Mode
Enter the values of xa,ya,xb,yb
dx=abs(xa-xb) dy =abs(ya-yb) K=2*(dy-dx)
If (xa >xb)
X =xb Y=yb Xe=xb
X =xa Y=ya Xe=xb
Putpixel(x,y,1)
A
A
For (x<xe)
X=x+1
If(k>0)
Y=y+1 K+=2*(dy-dx)
K=k+2*dy
Next
Stop
PROGRAM: #include<stdio.h> #include #include<math.h> #include<stdlib.h> #include void main() { float xa,xb,ya,yb,dx,dy,k,xe,x,y; /* REQUEST AUTO DETECTION */ int gdriver = DETECT,gmode,errorcode; /* INITIALIZE GRAPHICS MODE */ initgraph(&gdriver,&gmode,""); printf("BRESENHAMS ALGORITHM \N enter the value\n"); scanf("%f%f%f%f",&xa,&ya,&xb,&yb); dx=abs(xa-xb); dy=abs(ya-yb); k=2*(dy-dx); if(xa>xb) { x=xb; y=yb; xe=xa; } else { x=xa; y=ya; xe=xb; } putpixel(x,y,1); while(x<xe) { x=x+ 1; if(k<0) k=k+2*dy; else { y=y+1; k+=2*(dy-dx); } putpixel(x,y, 1); } getch(); }
OUTPUT:
RESULT: Thus the program to implement the Bresenham’s Line drawing algorithm was executed successfully.
Exp No : Date : Mid Point Circle Drawing Algorithm AIM: To implement mid point circle drawing algorithm using C.
ALGORITM: Step 1: Input the radius and center point. Step 2: Calculate the initial value as po=5/4-r. Step 3: Perform the text pk
FLOWCHART: CIRCLE Start
Input radius, center point
p=1-radius x=0,y=radius
plotpoints
plotpoints Set the initial point For p<0
plotpoints
Calculate next points
Next
Stop
Set the symmetry points in other seven octants
PROGRAM: #include #include<stdio.h> #include #include<math.h> void plotpoints(int xc,int yc,int x,int y) { putpixel(xc+x,yc+y,5); putpixel(xc-x,yc+y,5); putpixel(xc+x,yc-y,5); putpixel(xc-x,yc-y,5); putpixel(xc+y,yc+x,5); putpixel(xc-y,yc+x,5); putpixel(xc+y,yc-x,5); putpixel(xc-y,yc-x,5); } void drawcircle(int xc,int yc,int radius) { int p,x=0,y=radius; plotpoints(xc,yc,x,y); p=1-radius; while(x
OUTPUT:
RESULT: Thus the program to implement the mid point circle drawing algorithm was executed successfully and output is verified.
Exp No : Date : LINE STYLES AIM: To write a program implementing the various line styles using C
ALGORITHM: Step Step Step Step
1: 2: 3: 4:
Input the line coordinates Set a line style Draw line using the line style Repeat steps 1,2 and 3 for all line styles
FLOWCHART: LINE STYLES
Start
For all line styles
Input line coordinates
Draw line with present line styles
Next
Stop
PROGRAM: #include #include<stdlib.h> #include void main() { int gd=DETECT,gm,maxy,x,style; char str[40]; struct linesettingstype ls; initgraph(&gd,&gm,""); maxy=getmaxy(); setcolor(RED); outtextxy(10,20,"normal width"); x=20; for(style=0;style<4;style++) { setlinestyle(style,0,1); getlinesettings(&ls); setlinestyle(style,0,1); line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; setlinestyle(ls.linestyle,ls.upattern,ls.thickness); } outtextxy(375,20,"thick width"); x=375; for(style=0;style<4;style++) x=375; for(style=0;style<4;style++) { setlinestyle(style,0,3); line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; setlinestyle(ls.linestyle,ls.upattern,ls.thickness); } getch(); closegraph(); restorecrtmode(); }
OUTPUT:
RESULT: Thus the program to implement different line styles is executed successfully.
Exp No : Date : Fill Pattern Styles AIM: To write a program implementing the various fill patterns using C.
ALGORITHM: Step Step Step Step Step
1: 2: 3: 4: 5:
Input the bar coordinates Set a fill pattern style Draw the bar line style Fill the bar using the fill pattern Repeat steps 1, 2, 3 and 4 for all lines.
FLOWCHART: FILL PATTERN STYLES
Start
For all fill patterns
Input bar coordinates
Draw bar Fill bar
Next
Stop
PROGRAM: #include #include<stdlib.h> #include void main() { int gd=DETECT,gm,maxx,maxy,x=40,y=40,fst; char str[40]; char *pattern[]={ "empty_fill","solid_fill","line_fill","ltslash_fill", "ltbkslash_fill","hatch_fill","xhatch_fill", "interleave_fill", "wide_dot_fill","close_dot_fill","user_fill"}; initgraph(&gd,&gm,""); maxx=getmaxx(); maxy=getmaxy(); rectangle(0, 10,maxx,maxy); setcolor(MAGENTA); outtextxy(175,0,"pre defined fill styles"); for(fst=0; fst< 12;fst++) { setfillstyle(fst,YELLOW); bar(x,y,x+80,y+80); itoa(fst,str,10); outtextxy(x,y+100,str); outtextxy(x,y+110,pattern[fst]); x+=150; if(x>490) { y+=150; x=40; } } getch(); closegraph(); restorecrtmode(); }
OUTPUT:
RESULT: Thus the program to implement the fill style patterns is executed successfully.
Exp No : Date : SHAPES AIM: To write a program in C to show the following shapes: 1. Cardiod 2. Threeleaf 3. Spiral 4. Fourleaf
ALGORITHM: Step 1: Input the shape to be drawn Step 2: Input the center points and size factors Step 3: Set the values of pi,twopi,theta,dtheta Step 4: Calculate theta,dtheta and other constants for the given shape Step 5: Draw the shape Step 6: Repeat steps 4 and 5 till the shape is complete
FLOWCHART: SHAPES
Start
Input Shape Input Shape Details
Initialise pi, twopi, theta, dtheta
For (shape is continued
Calculate theta dtheta for the given shape Draw points
Next
Stop
PROGRAM: #include #include<stdlib.h> #include void main() { int gd=DETECT,gm,maxy,x,style; char str[40]; struct linesettingstype ls; initgraph(&gd,&gm,""); maxy=getmaxy(); setcolor(RED); outtextxy(10,20,"normal width"); x=20; for(style=0;style<4;style++) { setlinestyle(style,0,1); getlinesettings(&ls); setlinestyle(style,0,1); line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; setlinestyle(ls.linestyle,ls.upattern,ls.thickness); } outtextxy(375,20,"thick width"); x=375; for(style=0;style<4;style++) x=375;//shape generation, exp no - 8 #include<math.h> #include #include #include<stdio.h> struct wcp { int x,y; }; int fig; void polyline(int x, wcp *y) { for(int i=0;i<x;i++) line(y[i].x,y[i].y,y[i+1].x,y[i+1].y); } void drawcurlyfig(wcp center, float a, float b) { float twopi=6.28; float theta=0; float dtheta=1/a; float r; wcp pts[1000]; int cnt=0; pts[0].y=center.y; switch(fig) {case 0:{pts[0].x=(center.x)+(a*2);break;}
case 1: { pts[0].x=center.x+a; break; } case 2: { pts[0].x=center.x; break; } case 3: { pts[0].x=center.x-a; break; } } while(theta
printf("\nENTER YOUR CHOICE :"); scanf("%d",&fig); fig--; printf("Enter center point x,y:"); scanf("%d%d",&xx.x,&xx.y); printf("Enter size factors a,b:"); scanf("%f%f",&a,&b); initgraph(&gdriver, &gmode,""); cleardevice(); switch(fig) { case 0: { printf("CARDIOD"); drawcurlyfig(xx,a,b); getch(); break; } case 1: { printf("THREELEAF"); drawcurlyfig(xx,a,b); getch(); break; } case 2: { printf(" SPIRAL"); drawcurlyfig(xx,a,b); getch(); break; } case 3: { printf("FOURLEAF"); drawcurlyfig(xx,a,b); getch(); } } closegraph(); } for(style=0;style<4;style++) { setlinestyle(style,0,3); line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; setlinestyle(ls.linestyle,ls.upattern,ls.thickness);} getch(); closegraph(); restorecrtmode(); }
OUTPUT: 1:CARDIOD 2:THREELEAF 3:SPIRAl 4:FOURLEAF Enter your choice:2 Enter center point x,y Enter size factors a,b
35 45 5 8
Enter your choice: 3 Enter center point x,y Enter size factors a,b
55 65 4 6
RESULT: Thus the program to implement the shapes is executed successfully and output is verified.
Exp No : Date : WHEEL ROTATION
AIM: To write a program to show the rotation of a wheel using C.
ALGORITHM: Step 1: Input the center coordinates of the wheel Step 2: Input the number of spikes Step 3: Draw wheel
FLOWCHART: WHEEL ROTATION
Start
Input Center Input No of Spikes
Draw Wheel
For(Key not hit)
Calculate the next value of spikes Delay Draw Wheel
Next
Stop
PROGRAM: #include<stdio.h> #include #include<math.h> #include #include<dos.h> void main() { float k,k1; int n,xc,yc,r,i,xa,ya; void wcircle(int,int,int); int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,""); printf("Enter The Circle & Radius:"); scanf("%d %d %d",&xc,&yc,&r); printf("\nEnter The No. Of Slices:"); scanf("%d",&n); circle(xc,yc,r); k=6.28/n; k1=k; while(!kbhit()) { circle(xc,yc,r); for(i=0;i
OUTPUT: Enter circle radius and centre coordinates 50 200 200 Enter no of slices 8
RESULT: Thus the program to implement wheel rotation is executed successfully.
Exp No : Date : LINE CLIPPING AIM: To write a program to show the Clipping Window using C.
ALGORITHM: Step l: Initialize the graphics Step 2: Enter the coordinates for the Clipping Window Step 3: Enter the first coordinates of the line to be clipped Step 4: Enter the second coordinates of the line to be clipped Step 5: Declare afunction box() to draw the clipping window Step 6: Declare a functionaccept() to accept the points inside the clipping window Step 7: Declare a functionreject() to CLIP the points outside the clipping window.
FLOWCHART: LINE CLIPPING
Start
Initialize the Graphics
Enter the coordinates for clipping window
Enter the second coordinates for line
Enter the first coordinates for line
Declare a function box() to draw the clipping window Declare function accept() to retain the line inside the window Declare function reject() to CLIP the line outside the window
Stop
PROGRAM: #include #include #include<math.h> void box(); void encode(int k1,int y1,int c[5]); int accept(int a[4],int b[4]); int reject(int a[4],int b[4]); int ptinside(int a[5]); void swap(int *a,int *b); int wx1,wy1,wx2,wy2,a[6],b[6]; void main() { int gdriver=DETECT,gmode; int a[5],b[5]; int x1,y1,x2,y2,i,j; int done=0; int draw=0; float m; initgraph(&gdriver,&gmode," "); printf("\n\t\t LINE CLIPPING"); printf("\n\t\t----------"); printf("\n\t\t Enter window coordinates"); scanf("%d%d%d%d",&wx1,&wy1,&wx2,&wy2); printf("\n Coordinates for line"); scanf("%d%d",&x1,&y1); printf("\n Coordinates for line"); scanf("%d%d",&x2,&y2); cleardevice(); printf("\n\tBEFORE CLIPPING"); box(); line(x1,y1,x2,y2); cleardevice(); getch(); printf("\n\tAFTER CLIPPING"); box(); while(!(done)) { encode(x1,y1,a); encode(x2,y2,b); if(accept(a,b)) { done=1; draw=1; } else if(reject(a,b)) done=1; else if(ptinside(a)) { swap(&x1,&x2); swap(&y1,&y2); for(i=1;i<=4;i++) swap(&a[i],&b[i]); } m=(y2-y1)/(x2-x1);
if(a[1]) { y1=y1+(wx1-x1)*m; x1=wx1; } else if(a[2]) { y1= y1+(wx2-x1)*m; x1 =wx2; } else if(a[3]) { x1=x1+(wy1-y1)/m; y1=wy1; } else if(a[4]) { x1=x1+(wy2 -y1)/m; y1=wy2; } } box(); if(draw) line(x1,y1,x2,y2); getch(); } void box() { line( wx1,wy1,wx2,wy1); line( wx2,wy1,wx2,wy2); line( wx2,wy2,wx1,wy2); line( wx1,wy2,wx1,wy1); } void encode(int x , int y, int c[5]) { if(x<wx1) c[1] = 1; else c[1] = 0; if(x>wx2) c[2] = 1; else c[2] = 0; if(y<wy1) c[3] = 1; else c[3] = 0; if(y>wy2) c[4] = 1; else c[4] = 0; } int accept (int a[4] , int b[4] ) { int t =1; int i; for(i=1; i<=4; i++)
{ if(( a[i])||( b[i] )) t=0; } return(t); } int reject(int a[4] int b[4] ) { int t=0; int i; for( i=1;i<=4;i++) { if((a[i]) && (b[i])) t=1; } return(t); } int ptinside( int a[5]) { if((a[1])||(a[2])||(a[3])||(a[4])) return(0); else return(1); } void swap(int *a, int *b) { int *temp; *temp =*a; *a= *b; *b =*temp; }
OUTPUT:
RESULT: Thus the program to implement the line clipping is executed successfully
Exp No : Date : 2D - Transformation AIM: To write a program to show the 2D - Transformation using C.
ALGORITHM: Step 1: Initialize the graphics Step2: Enter the Your Choice. Step 3: If the choice is Shifting enter the circles coordinate&c,yc,r Step 4: If the choice is Scaling enter the scaling value. Step 5: If the choice is rotating enter the angle. Step 6: Declare a funetioncircleQ to accept the points inside the circle. Step 7: Calculate Shifting, Scaling and other constants for the given shape . Step 8: Draw the shape. Step 9: Repeat steps 7 nd 8 till the shape is complete.
FLOWCHART: 2D TRANSFORMATION
Start
Enter your choice for Shifting Scaling Rotating Read K
K
shifting
scaling
A
B
Closegraph
Stop
rotation
C
PROGRAM: #include #include<dos.h> #include<math.h> #include<stdlib.h> #include int xc,yc,r,x,y,p,g,s,i,k; float q; void main() { int gdriver=DETECT,gmode,errorcode; initgraph(&gdriver,&gmode,""); printf("\nl.shifting\n2.scaling\n3.rotation"); printf("\nenter your choice : "); scanf("%d",&k); switch(k) { case 1: { printf("CIRCLE DRAWING ALGORITHM\n enter the value for xc yc r: "); scant("%d%d%d",&xc,&yc,&r); circle(xc,yc,r); printf("\nenter the position to shift: "); scanf("%d",&s); for(i=0;i<s;i++) { xc++; yc++; cleardevice(); circle(xc,yc,r); delay(60); } break; } case 2: { printf("CIRCLE DRAWING ALGORITHM\n enter the value for xc yc r: "); scanf("%d%d%d",&xc,&yc,&r); circle(xc,yc,r); printf("\nenter the value for scaling: "); scanf("%d",&g); for(i=0;i
x=200;y=200; moveto(200,200); lineto(300,200); printf("\n enter an angle: "); scanf("%f",&q); q=3.14*q/180; x=200+100*cos(q); y=200+100*sin(q); cleardevice(); moveto(200,200); lineto(x,y); break; } } getch(); closegraph(); }
OUTPUT:
Enter your choice : 1 Circle Drawing Algorithm Enter the value for xc yc r : 100 100 35 Enter new position : 150 150
Enter your choice : 3
RESULT: Thus the program to implement to show the 2-D transformation is compiled and executed successfully.
Exp No : Date : BAR CHART AIM: To write a program to plot a bar chart for some given data using C.
ALGORITHM: Step 1: Input statistical data for each month Step 2: Draw labels for each month Step 3: Calculate the bar points for each month Step 4: Calculate left, top, right and bottom points for bar of the present month. Step 5: Draw the bar Step 6: Calculate coordinates for next month Step 7: Repeat steps 4,5 and 6 for all months
FLOWCHART: BAR CHART
Start
Input values for each Month
Draw Labels Calculate Bar points
For all months
Find left, top, right, bottom axis of the bar Draw the Bar
Next i
Stop
PROGRAM:
#include<stdio.h> #include #include<string.h> #include<math.h> #include int const monthcount=l2,dataoffset=l8; struct indata { float realarray[12]; float array[ 12]; } char getlabel[3]; indata data; int monthplace[12]; float interval,chartbottom,radius; struct wcp { float x; float y; } coord[monthcount]; wcp center; int round(float a) { int b; b=a; if(a-b>0.5) return ++b; else return b; } void mybar(int x, wcp *y) { setfillstyle(SOLID_FILL,8); for(int i=0;i<x;i++) bar(y[i].x,y[i].y,y[i].x+40,chartbottom-dataoffset); } void getlab(int x) { switch(x) { case 0: { strcpy(getlabel,"JAN"); break; } case 1: { strcpy(getlabel,"FEB"); break; } case 2: { strcpy(getlabel ,"MAR"); break; } case 3: {
strcpy(getlabel,"APR"); break; } case 4: { strcpy(getlabel,"MAY"); break; } case 5: { strcpy(getlabel,"JUN"); break; } case 6: { strcpy(getlabel,"JUL"); break; } case 7: { strcpy(getlabel,"AUG"); break; } case 8: { strcpy(getlabel,"SEP"); break; } case 9: { strcpy(getlabel,"OCT"); break; } case 10: { strcpy(getlabel,"NOV"); break; } case 11: { strcpy(getlabel,"DEC"); break; } } } void getdata() { float t1=0.00,t2; for(int t=0;t<12;t++) getlab(t); printf("ENTER THE DATA FOR THE MONTH OF %s ",getlabel); scanf("%f ",&data.realarray[t]); if(data.realarray[t]>t1 ) tl =data.realarray [t]; for(t=0;t<12;t++) { t2=data.realarray[t]/t1 ;
data.array[t]=t2*400; } } void puttext(wcp textp) { settextstyle(1,HORIZ_DIR,1); outtextxy(textp.x,textp.y,getlabel); } void drawlabels() { wcp textposition; textposition.y=chartbottom; int zz=25; for(int az=0;az<12;az++) { textposition.x=zz; zz+=50; getlab(az); puttext(textposition); } } char valuep[5]; void findvaluep(int x) { int y=x,ttt; char tg[5]; strcpy(tg,""); do { ttt=y%10; switch(ttt) { case 0: { strcat(tg,"0"); break; } case 1: { strcat(tg,"1"); break; } case 2: { strcat(tg,"2"); break; } case 3: { strcat(tg,"3"); break; } case 4: { strcat(tg,"4"); break; }
case 5: { strcat(tg,"5 "); break; } case 6: { strcat(tg,"6"); break; } case 7: { strcat(tg,"7"); break; } case 8: { strcat(tg,"8"); break; } case 9: { strcat(tg,"9"); break; } } y/=10; } while(y>0); strcpy(valuep,""); for(y=0;y<strlen(tg);y++) valuep[y]=tg[strlen(tg)-y-1]; valuep[y]=NULL; } void barchart() { drawlabels(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); for(int t=0;t<monthcount;t++) { coord[t].x=monthplace[t]; coord[t].y=450-data.array [t]-dataoffset; findvaluep(data.realarray[t]); outtextxy(coord[t].x,coord[t].y-l 0,valuep); } mybar(monthcount,coord); } void main() { int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,""); getdata(); cleardevice(); chartbottom=450.0; interval=50.0; monthplace[0]=25; for(int z=1;z<monthcount;z++) monthplace[z]=monthplace[z-1 ]+interval;
linechart(); getch(); cleardevice(); barchart(); getch(); cleardevice(); center.x=300; center.y=205; radius=200; piechart(); getch(); closegraph(); }
OUTPUT
RESULT: Thus the program to implement to show the Bar Chart is compiled and executed successfully.
Exp No : Date :
LINE CHART AIM: To write a program to plot a line chart for some given data using C.
ALGORITHM: Step Step Step Step Step
1: 2: 3: 4: 5:
Input statistical data for each month Draw labels for each month Calculate the value points for each month Let p=pointl and q=point2 Draw a line joining p and q
FLOWCHART: LINECHART
Start
Input values for each Month
Draw Labels Set p & q
For all points
Draw a line between p and q Get next values of p and q
Next i
Stop
PROGRAM: #include<stdio.h>
#include #include<string.h> #include<math.h> #include int const monthcount=12,dataoffset=18; struct indata { float realarray[ 12]; float array[ 12]; } char getlabel[3]; indata data; int monthplace[ 12]; float interval,chartbottom,radius; struct wcp { float x; float y; } coord[monthcount]; wcp center; int round(float a) { int b; b=a; if(a-b>0.5) return ++b; else return b; } void polyline(int x, wcp *y) { for(int i=0;i<x-l ;i++) line(y[i].x,y[i].y,y[i+l ].x,y[i+l ].y); } void getlab(int x) { switch(x) { case 0: { strcpy(getlabel,"JAN"); break; } case 1: { strcpy(getlab ,"FEB"); break; } case 2: { strcpy(getlabel," MAR"); break; } case 3: { strcpy(getlabel,"APR"); break;
} case 4: { strcpy(getlabel,"MAY"); break; } case 5: { strcpy(getlabel,"JUN"); break; } case 6: { strcpy(getlabel,"JUL"); break; } case 7: { strcpy(getlabel,"AUG" ); break; } case 8: { strcpy(getlabel,"SEP"); break; } case 9: { strcpy(getlabel,"OCT"); break; } case 10: { strcpy(getlabel,"NOV"); break; } case 11: { strcpy(getlabel,"DEC"); break; } } } void getdata() { float t1=0.00,t2; for(int t=0;t<12;t++) getlab(t); printf("ENTER THE DATA FOR THE MONTH OF %s: ",getlabel); scanf("%f",&data.realarray[t]); if(data.realarray(t)>tl ) { t1=data.realarray[t]; } for(t=0;t<12;t++) { t2=data.realarray[t]/t 1;
data.array[t]=t2*400; } } void puttext(wcp textp) { settextstyle(1,HORIZ_DIR,1); outtextxy(textp.x,textp.y,getlabel); } void drawlabels() { wcp textposition; textposition.y=chartbottom; int zz=25; for(int az=0;az<12;az++) { textposition.x=zz; zz+=50; getlab(az); puttext(textposition); } } char valuep[5]; void findvaluep(int x) { int y=x,ttt; char tg[5]; strcpy(tg,""); do { ttt=y%10; switch(ttt) { case 0: { strcat(tg,"0"); break; } case 1: { strcat(tg,"1"); break; } case 2: { strcat(tg,"2"); break; } case 3: { strcat(tg,"3"); break; } case 4: { strcat(tg,"4"); break; }
case 5: { strcat(tg,"5"); break; } case 6: { strcat(tg,"6"); break; } case 7: { strcat(tg,"7"); break; } case 8: { strcat(tg,"8"); break; } case 9: { strcat(tg,"9"); break; } y/=10; } while(y>0); strcpy(valuep,""); for(y=0;y<strlen(tg);y++) { valuep[y]=tg[strlen(tg)-y-1]; } valuep[y]=NULL; } } void linechart() { drawlabels(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); for(int t=0;t<monthcount;t++) { coord[t].x=monthplace[t]; coord[t].y=450-data.array[t]-dataoffset; findvaluep(data.realarray[t]); outtextxy(coord .x,coord[t].y-l0,valuep); } polyline(monthcount,coord); } void main() { int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,""); getdata(); cleardevice(); chartbottom=450.0; interval=50.0; monthplace[0]=25;
for(int z=1;z<monthcount;z++) monthplace[z]=monthplace[z-1 ]+interval; linechart(); getch(); cleardevice(); closegraph(); }
OUTPUT
RESULT: Thus the program to implement to show the Line Chart is compiled and executed successful
Exp no –
Date Logo Creation Aim: To create a logo using various tools of Adobe Photoshop 7.0
Algorithm: Step 1: Create a new canvas to draw logo of size appropriate for a logo. Step 2: Select simple grid in gradient tool. Step 3: Select an area in the middle of the logo using rectangle marquee tool. Step 4: Select the White-Blue-White grid in gradients and use it in the selected part. Step 5: Select text tool and write the contents on the middle section of the logo. Step 6: Use different fonts and sizes for attractive text. Merge layers now. Step 7: Use smudge tool to smudge the background of the text and give it a design. Step 8: Save it as LOGO.JPG. Step 9: Exit
Output
Result: The logo has been created successfully.
Exp – Date – Displacement Effect Aim: -
To create a flag using displacement effect.
Algorithm: Step 1: Select a grid in gradient tool with 3 colour slides. Step 2: Set the desired colours. Step 3: Use gradient to create a gradient of three layers. Step 4: Create a new document. Step 5: Create another gradient with many alternate slides of two colours. Step 6: Use it to create a pattern in new file. Step 7: Select the new file’s contents and drag it to the first one. Step 8: Set overlay in the layer properties. Step 9: Merge the layers. Step 10: Save and Exit.
Output
Result: The flag has been created successfully using displacement effect.
Exp – Date – Animation Effect Aim: To create animation effect in simple JPG file using tween and liquefy effect.
Algorithm: Step 1: Create another layer of an image by copying. Step 2: Select copy layer and use smudge tool to slightly change the image. Step 3: Use liquefy tool to slightly move image parts. Step 4: Use Image Ready to put tween effect in the photo. Give proper time dilation; select the correct layer to be displayed. Step 5: Save the image as .PSD or .GIF. Step 6: Use Open it in Internet Explorer and save the web page.
OUTPUT
Original:
Animated:
Result: The program is written and executed successfully.
Expt no: Date : MIRROR IMAGE Aim To use Adobe Photoshop CS 9 to make a mirror image of a given picture. Steps 1. Open the picture you want to modify 2. Change the Canvas Size ( Image Canvas Size ) and make the height as 200%
3. Move the Image to the top right position and create a duplicate layer of the same image ( Right click the layer and select “Duplicate” or press Ctrl + J ) 4. Move the duplicated layer to the bottom. 5. Invert the image : Edit Transform Flip Vertical 6. Apply some “Ocean Ripple” effect from Filters Menu to give some water ripple effect on the inverted image. ( Filter Distort Ocean Ripple)
EXPT NO. : DATE : Aim
Morph a Person’s Face
To use Adobe Photoshop CS 9 to morph a person
face.
Steps 1. Open the image you want to modify 2. Use the Liquify ( Filter Liquify or press Shift + Ctrl + X ) 3. Use various tools on the Liquify window to alter the person’s face. The various available tools are Warp Tool Wave Tool Swirl Tool Shrink Tool Expand Tool Move Left Tool Mirror Tool Undo Tool
Initial Picture :
Final Picture :
Result:
Thus, using Photoshop CS9 the face was morphed.