Sutherland-Hodgeman polygon clipping algorithm Aim:- To write a C program to implement polygon clipping. Procedure Algorithm For Polygon Clipping 1. Get the minimum and maximum coordinates of both window and view port. 2. Get the number of sides of a polygon and its corresponding coordinates. 3. If the polygon lies within region code window, display it. 4. If any one of the polygon side is neither inside nor outside the boundary, find point of intersection and clip the regions that lies outside the boundary. 5. Display the polygon after clipping. Source Code Programming in C #include<stdio.h> #include<conio.h> #include<graphics.h> typedef enum { left,right,bottom,top } edge; #define N_EDGE 4 #define TRUE 1 #define FALSE 0 struct point { int x; int y; }p,wmin,wmax,p1,p2,ipt,i,pin[50],pout[50],first[50],s[50],i; int inside(struct point p,int b,struct point wmin,struct point wmax) { switch(b) { case left: if(p.x<wmin.x) return (FALSE);
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Sutherland-Hodgeman polygon clipping algorithm
Aim:- To write a C program to implement polygon clipping.
Procedure Algorithm For Polygon Clipping 1. Get the minimum and maximum coordinates of both window and view port.2. Get the number of sides of a polygon and its corresponding coordinates.3. If the polygon lies within region code window, display it.4. If any one of the polygon side is neither inside nor outside the boundary, find point of intersection and clip the regions that lies outside the boundary.5. Display the polygon after clipping.
Source Code Programming in C #include<stdio.h>#include<conio.h>#include<graphics.h>typedef enum { left,right,bottom,top } edge;#define N_EDGE 4#define TRUE 1#define FALSE 0struct point{int x;int y;}p,wmin,wmax,p1,p2,ipt,i,pin[50],pout[50],first[50],s[50],i;int inside(struct point p,int b,struct point wmin,struct point wmax){switch(b){case left:if(p.x<wmin.x)return (FALSE);break;case right:if(p.x>wmax.x)return (FALSE);break;case bottom:if(p.y<wmin.y)return (FALSE);break;case top:if(p.y>wmax.y)return (FALSE);break;
}return (TRUE);}int cross(struct point p1,struct point p2,int b,struct point wmin,struct point wmax){if(inside(p1,b,wmin,wmax)==inside(p2,b,wmin,wmax))return (FALSE);elsereturn (TRUE);}struct point intersect(struct point p1,struct point p2,int b,struct point wmin,struct point wmax){float m;if(p1.x!=p2.x)m=(p1.y-p2.y)/(p1.x-p2.x);switch(b){case left:ipt.x=wmin.x;ipt.y=p2.y+(wmin.x-p2.x)*m;break;case right:ipt.x=wmax.x;ipt.y=p2.y+(wmax.x-p2.x)*m;break;case bottom:ipt.y=wmin.y;if(p1.x!=p2.x)ipt.x=p2.x+(wmin.y-p2.y)/m;elseipt.x=p2.x;break;case top:ipt.y=wmax.y;if(p1.x!=p2.x)ipt.x=p2.x+(wmax.y-p2.y)/m;elseipt.x=p2.x;break;}return(ipt);}void clippoint(struct point p,int b,struct point wmin,struct point wmax,struct point *pout,int *cnt,struct point *first[],struct point *s){if(!first[b])
first[b]=&p;elseif(cross(p,s[b],b,wmin,wmax)){ipt=intersect(p,s[b],b,wmin,wmax);if(b<top)clippoint(ipt,b+1,wmin,wmax,pout,cnt,first,s);else{pout[*cnt]=ipt;(*cnt)++;}}s[b]=p;if(inside(p,b,wmin,wmax))if(b<top)clippoint(p,b+1,wmin,wmax,pout,cnt,first,s);else{pout[*cnt]=p;(*cnt)++;}}void closeclip(struct point wmin,struct point wmax,struct point *pout,int *cnt,struct point *first[],struct point *s){int b;for(b=left;b<=top;b++){if(cross(s[b],*first[b],b,wmin,wmax)){i=intersect(s[b],*first[b],b,wmin,wmax);if(b<top)clippoint(i,b+1,wmin,wmax,pout,cnt,first,s);else{pout[*cnt]=i;(*cnt)++;}}}}int clippolygon(struct point wmin,struct point wmax,int n,struct point *pin,struct point *pout){struct point *first[N_EDGE]={0,0,0,0},s[N_EDGE];int i,cnt=0;
for(i=0;i<n;i++)clippoint(pin[i],left,wmin,wmax,pout,&cnt,first,s);closeclip(wmin,wmax,pout,&cnt,first,s);return(cnt);}void main(){int c,gm,gr,n,j,np;clrscr();detectgraph(&gm,&gr);initgraph(&gm,&gr,"d:\\tc\\BGI");printf("Enter the window minimum coordinates");scanf("%d%d",&wmin.x,&wmin.y);printf("Enter the window max coordinates");scanf("%d%d",&wmax.x,&wmax.y);rectangle(wmin.x,wmax.y,wmax.x,wmin.y);printf("Enter the no of sides in polygon:\n");scanf("%d",&n);printf("Enter the coordinates(x,y)for pin ,pout:\n");for(j=0;j<n;j++){scanf("%d%d",&pin[j].x,&pin[j].y);scanf("%d%d",&pout[j].x,&pout[j].y);}detectgraph(&gm,&gr);initgraph(&gm,&gr,"d:\\tc\\BGI");for(j=0;j<n;j++){if(j!=n-1)line(pin[j].x,pin[j].y,pout[j].x,pout[j].y);elseline(pin[j].x,pin[j].y,pout[j].x,pout[j].y);}rectangle(wmin.x,wmax.y,wmax.x,wmin.y);printf("\n1.polygon clipping 2.exit");scanf("%d",&c);switch(c){case 1:detectgraph(&gm,&gr);initgraph(&gm,&gr,"d:\\tc\\BGI");rectangle(wmin.x,wmax.y,wmax.x,wmin.y);np=clippolygon(wmin,wmax,n,pin,pout);for(j=0;j<np;j++){line(pout[j].x,pout[j].y,pout[(j+1)].x,pout[(j+1)].y);
}break;case 2:exit(0);}getch();}
Project Example Output Enter the window minimum coordinates200200Enter the window max coordinates400400Enter the no of sides in polygon3Enter the coordinates(x,y)for pin ,pout1503002501752501753504103504101503001.polygon clipping 2.exit RESULT Thus the c program to implement polygon clipping was coded and executed successfully.
EX. NO.:-
DATE:-
Visualization of 3-Dimensional Images Algorithm
These Program is draw the three dimensional image using bard3d graphics function. using maxx=getmaxx();maxy=getmaxy(); it will get the center of the coordinate using these coordinate it will draw the three dimensional visualization imageSource code three Dimensional Image algorithm #include<stdio.h>#include<conio.h>#include<graphics.h>#include<math.h>int maxx,maxy,midx,midy;void axis(){getch();cleardevice();line(midx,0,midx,maxy);line(0,midy,maxx,midy);}void main(){int gd,gm,x,y,z;clrscr();detectgraph(&gd,&gm);initgraph(&gd,&gm,"c:/tc/bgi");setfillstyle(0,getmaxcolor());maxx=getmaxx();maxy=getmaxy();midx=maxx/2;midy=maxy/2;bar3d(midx-250,midy+150,midx-150,midy+225,20,4);printf("\nEnter the Perspective Projection Vector");scanf("%d%d%d",&x,&y,&z);bar3d(midx-(x*5),midy-(y*9),midx-(x*3),midy-(y*5),10*z,4);getch();closegraph();}
AIM: To implement Bresenham’s line drawing Algorithm for drawing lines.
FUNCTIONS USED:Line ()
The function line () is used to draw a line from(x1, y1) to (x2, y2) Syntax:
line (x1,y1,x2,y2)initgraph().
This function takes thee arguments and they are i).the video driver to be used (gd). ii).the graphics mode (gm). iii).the path name.
Syntax Initgraph(gd,gm,path)
ALGORITHM:
Step 1: StartStep 2: Get the values of the end points as(x1, y1) &(x2, y2)Step 3: Assign x=x1, y=y1;Step 4: Compute dx=x2-x1Step 5: Compute dy=y2-y1Step 6: Assign sx=x2-x1, sy=y2-y1Step 7: If dy>dx then interchange the values of dx and dy and assign exch=1Step 8: Compute p=2xdy-dxStep 9: Put a pixel on(x,y)Step 10: If exch=1, y=sy else x=x+sxStep 11: If p>0 and exch =1, x=x+sx else y=y+sy, p=p-2xdxStep 12: Compute p=p+2xdyStep 13: Do steps (9) t0 (12) for dx timesStep 14: Stop
PROGRAM:
#include<iostream.h>#include<graphics.h>#include<conio.h>#include<math.h> int signs(int m);void bres_line(int,int,int,int);void main(){int gd=DETECT,gm;int x1,x2,y1,y2;initgraph(&gd,&gm,"");cout<<"enter starting value of X-Axis----->";cin>>x1;cout<<"enter starting value of Y-Axis----->";cin>>y1;cout<<"enter ending value of X-Axis----->";cin>>x2;cout<<"enter ending value of y-Axis----->";cin>>y2;bres_line(x1,y1,x2,y2);getch();closegraph();}void bres_line(int x1,int y1,int x2,int y2){int x,y,sx,sy,p,temp,exch=0,i,dx,dy;x=x1;y=y1;dy=abs(y1-y2);dx=abs(x1-x2);sx=signs(x2-x1);sy=signs(y2-y1);if(dy>dx){temp=dx;dx=dy;dy=temp;exch=1;}p=2*dy-dx;for(i=0;i<=dx;i++){putpixel(x,y,15);
Enter starting value of X-Axis----->100Enter starting value of Y-Axis----->100Enter ending value of X-Axis----->200Enter ending value of Y-Axis----->200
OUTPUT:
RESULT: Thus the program is executed and verified.
EX. NO. 1(B)DATE:
CIRCLE DRAWING
AIM: To write a program to draw a circle using Bresenham’s circle drawing Algorithm.
FUNCTIONS USED:Circle()
The function circle() is used to draw a circle using(x,y) as centre point. Syntax:
circle (x,y,radius)initgraph().
This function takes thee arguments and they are i).the video driver to be used (gd). ii).the graphics mode (gm). iii).the path name.
Syntax: Initgraph(gd,gm,path)Putpixel () The function putpixel() is used to place a pixel at particular coordinate
Syntax:
Putpixel(x,y,color)
ALGORITHM:
Step 1: Start
Step 2: Get the center point as (xc,yc),get the radius as r.
Step 3: Assign y=r,x=0
Step 4: Calculate p=3-2r
Step 5: If p<0,p=p+4x+6 else p=p+10+4(x-y) and y=y-1
Enter X-Axis----->:100Enter Y-Axis----->:200Enter radius----->: 40
OUTPUT:
:
RESULT: Thus the program is executed and verified.
EX. NO. 1(C)DATE:
MIDPOINT ELLIPSE DRAWING ALGORITHM
AIM
To write a C / C++ program to draw an ellipse using midpoint ellipse algorithm.
Algorithm
Step 1: Input radius rx, ry and ellipse center (Xc, Yc) and obtain the first point on the circumference of a
circle centered on the origin as (X0, Y0) = (0, ry)
Step 2: Calculate the initial values of the decision parameter in region 1 as
P10 = r2y – r2
x ry + 1/4 r2x
Step 3: At each Xk position in region 1, starting at k = 0, perform the following test:
If P1k < 0, the next point to plot is (Xk+1, Yk) and
P1k+1 = P1k+2 r2yXk+1 + r2
y
Otherwise the next point is (Xk+1, Yk-1) and
P1k+1 = P1k+2 r2yXk+1 - 2r2
xYk+1 + r2y
With
2 r2yXk+1=2 r2
yXk+ 2r2y
2r2xYk+1=2r2
xYk- 2r2x
Step 4: Calculate the initial values of the decision parameter in region 2 as
P20 = r2y(X0+1/2)2+ r2
x(Y0 – 1)2- r2x r2
y
Step 5: At each position starting at Yk position in region 2, starting at k = 0,
perform the following test:
If P2k > 0, the next point to plot is (Xk, Yk-1) and
P2k+1 = P2k - 2 r2yYk+1 + r2
x
Otherwise the next point is (Xk+1, Yk-1) and
P2k+1 = P2k - 2 r2yXk+1 - 2r2
xYk+1 + r2x
Step 6: Determine symmetry points in the other three octants
Step 7: Move each pixel position(X, Y) onto the circular path centered on
(Xc, Yc) and plot the coordinate values as
X = X + Xc Y = Y + Yc
Step 8: Repeat steps for region 1 until 2 r2yX>=2 r2
xY
FUNCTIONS USED:
initgraph().
This function takes thee arguments and they are i).the video driver to be used (gd). ii).the graphics mode (gm). iii).the path name.Syntax:
Initgraph(gd,gm,path)
Putpixel ()
The function putpixel() is used to place a pixel at particular coordinate
Syntax:
Putpixel(x,y,color)
ALGORITHM:
Step 1: Start
Step 2: Get the center point as(x1, y1)
Step 3: Get the length of semi-major, semi-minor axes as r1 & r2
Step 4: Calculate t=pi/180
Step 5: Initialise i=0;
Step 6: Compute d=i*t
Step 7: Compute x=x1+y1*sin(d), y=y1+r2*cos(d).
Step 8: Put a pixel on(x,y)
Step 9: Increment I by 1
Step 10: Repeat steps(6) to (9) until i<360
Step 11: Stop
PROGRAM:
#include<iostream.h>#include<graphics.h>#include<conio.h>#include<math.h>void main(){int gd=DETECT,gm,x1=0,y1=0,r1=0,r2=0;float x=0,y=0,t,d,i;initgraph(&gd,&gm,"");cout<<"enter the center co-or:";cin>>x1>>y1;cout<<"enter the radius1:";cin>>r1;cout<<"enter radius2:";cin>>r2;for(i=0;i<360;i++)
RESULT: Thus the program is executed and verified.
EX. NO. 2DATE:
IMPLEMENTATION OF LINE,CIRCLE & ELLIPSE ATTRIBUTES
Aim:
To write a C / C++ Program to display the various attributes of line, circle and ellipse.
Algorithm:
1. Start the program .
2. Initialize the variables.
3. Call the initgraph() function
4. Set color for the output primitives.
5. Using Outtextxy() display the chosen particular primitives.
6. Include the various attributes of line, circle and ellipse.
7. close the graph and run the program.
8. stop the program.
Ex. No. 5DATE: COHEN-SUTHERLAND CLIPPING
AIM: To implement Cohen-Sutherland clipping Algorithm.
FUNCTIONS USED:
Line() The function line () is used to draw a line from(x1,y1)to (x2,y2)
Syntax: line (x1,y1,x2,y2)
initgraph(). This function takes thee arguments and they are i).the video driver to be used (gd). ii).the graphics mode (gm). iii).the path name.
Syntax: Initgraph(gd,gm,path)
Setcolor(). This function changes the drawing colour.
Syntax: Setcolor(value of the color)
Settextstyle().The function settextstyle() is used to change the style of the text.
Syntax:Settextstyle(font,direction,charsize)
Where font is the constant value or the font filename, direction is the number either 0 or 1, which makes the output to display in horizontal, or in vertical direction, charsize is the character size or magnification factor and it varies from 1 to 10.
Outtext().This function display a text message on upper left of the screen
Syntax: Outtext(“message”);
ALGORITHM:
Step 1: Create a class sulc with functions drawwindow, drawline, setcode, visibility and
reset endpoint.
Step 2: Using the function line set the parameters to draw window.
Step 3: Using the function defined in class sulc, setcode is used to save the line inside the
window and to the line outside the window.
Step 4: Using the function visibility
i).check the code to know the points inside or outside the window.
ii).if the code value is zero the point is inside the window.
Step 5: Using the function reset end point
i). if the code value for the line is outside the window.
ii).reset the endpoint to the boundary of the window.
Step 6: Initialize the graphics functions
Step 7: Declare the variables x1, x2, y1, y2 of array type.
Step 8: Get the value of two endpoints x1, y1 and x2, y2 to draw the line.
Step 9: Using the object c, display the window before clipping.
Step 10: Using the function setcode, visibility display the clipped window only with lines
inside the window class was displayed after clipping.
if(temp.y<=350 &&temp.y>=100)return(temp);}if(p1.code[0]=='1')y=100;if(p1.code[1]=='1')y=350;if((p1.code[0]=='1')||(p1.code[1]=='1')){m=(float)(p2.y-p1.y)/(p2.x-p1.x);k=(float)p1.x+(float)(y-p1.y)/m;temp.x=k;temp.y=y;for(i=0;i<4;i++)temp.code[i]=p1.code[i];if(temp.y<=350 &&temp.y>=100)return(temp);}elsereturn(p1);}void main(){int gd=DETECT,gm,v;sulc c1;pt p1,p2,ptemp;initgraph(&gd,&gm,"");int x1[10],y1[10],x2[10],y2[10];cleardevice();int i,n;settextstyle(4,0,4);outtext("cohen sutherland line clipping");cout<<"\n\n enter the no.of lines:";cin>>n;for(i=0;i<n;i++){cout<<"\n\n enter end-point1(x1,y1):";cin>>x1[i]>>y1[i];cout<<"\n\n enter end-point2(x2,y2):";cin>>x2[i]>>y2[i];}cleardevice();settextstyle(0,0,3);outtext("before clipping");c1.drawwindow();for(i=0;i<n;i++)
e). using the function line,display the object before and after rotation.
Step9: Scaling:
a).input the scaling factor and reference point
b).calculate new coordinate point using formula
xa1[i]=(xa[i]*sx+rx*(1-sx),
ya1 [i] = (ya[i]*sy+ry*(1-sy)
c). using the function line, display the object before and after scaling.
Step10: Shearing:
a).input the shearing value and reference point.
b). input the shear direction x or y
i).if direction x
xa1[i]=xa[i]+shx*(ya[i]-yref)
ii).otherwise
ya1[i]=ya[i]+shy*(xa[i]-xref)
iii). using the function line, display the object before and after shearing.
Step11: Reflection:
a).display the object before reflection using the function line
b). display the object after reflection using the function line
Step12: Stop.
PROGRAM:
#include<iostream.h>#include<conio.h>#include<math.h>#include<graphics.h>#include<stdlib.h>void main(){int gd,gm,n,i,xa[10],ya[10],op,tx,ty,xa1[10],ya1[10],theta,xf,yf,rx,ry,sx,sy,shx,shy,xref,yref;char d;gd=DETECT;initgraph(&gd,&gm,"");cout<<"enter the no of points";cin>>n;for(i=0;i<n;i++){cout<<"enter the coordinates"<<i+1;cin>>xa[i]>>ya[i];}
do{cout<<"menu";cout<<"\n1.translation\n2.rotation\n3.scaling\n4.shearing\n5.reflection\n6.exit";cin>>op;switch(op){case 1:cout<<"enter the translation vector";cin>>tx>>ty;for(i=0;i<n;i++){xa1[i]=xa[i]+tx;ya1[i]=ya[i]+ty;}cout<<"before translation";for(i=0;i<n;i++){line(xa[i],ya[i],xa[(i+1)%n],ya[(i+1)%n]);} cout<<"after translation";for(i=0;i<n;i++){
line(xa1[i],ya1[i],xa1[(i+1)%n],ya1[(i+1)%n]);}getch();cleardevice();break;case 2:cout<<"enter the rotation angle";cin>>theta;theta=(theta*3.14)/180;cout<<"enter the reference points";cin>>xf>>yf;for(i=0;i<n;i++){xa1[i]=xf+(xa[i]-xf)*cos(theta)-(ya[i]-yf)*sin(theta);ya1[i]=yf+(xa[i]-xf)*sin(theta)-(ya[i]-yf)*cos(theta);}cout<<"before rotation";for(i=0;i<n;i++){line(xa[i],ya[i],xa[(i+1)%n],ya[(i+1)%n]);}
cout<<"after rotation";for(i=0;i<n;i++){line(xa1[i],ya1[i],xa1[(i+1)%n],ya1[(i+1)%n]);}getch();cleardevice();break;case 3:cout<<"enter the scaling factor";cin>>sx>>sy;cout<<"enter the reference point";cin>>rx>>ry;for(i=0;i<n;i++){xa1[i]=xa[i]*sx+rx*(1-sx);ya1[i]=ya[i]*sy+ry*(1-sy); }cout<<"before scaling";for(i=0;i<n;i++){line(xa[i],ya[i],xa[(i+1)%n],ya[(i+1)%n]);} cout<<"after scaling";
for(i=0;i<n;i++){line(xa1[i],ya1[i],xa1[(i+1)%n],ya1[(i+1)%n]);}getch();cleardevice();break;case 4:cout<<"enter the shear value";cin>>shx>>shy;cout<<"enter the reference point";cin>>xref>>yref;cout<<"enter the shear direction x or y";cin>>d;if(d=='x'){for(i=0;i<n;i++){xa1[i]=xa[i]+shx*(ya[i]-yref);ya1[i]=ya[i]; }}cout<<"before shearing";for(i=0;i<n;i++){line(xa[i],ya[i],xa[(i+1)%n],ya[(i+1)%n]);}cout<<"after shearing";for(i=0;i<n;i++){line(xa1[i],ya1[i],xa1[(i+1)%n],ya1[(i+1)%n]);}getch();cleardevice();break;case 5:cout<<"before reflection";for(i=0;i<n;i++){line(xa[i],ya[i],xa[(i+1)%n],ya[(i+1)%n]);} cout<<"after reflection";for(i=0;i<n;i++){line(ya[i],xa[i],ya[(i+1)%n],xa[(i+1)%n]);}
int i,x1[8],y1[8],x2[8],y2[8],z1[8],x3[8],y3[8],z3[8],x4[8],y4[8],theta,op,ch,tx,ty,tz,sx,sy,sz,xf,yf,zf,x,y,z,size;int driver=DETECT;int mode;initgraph(&driver,&mode,"");cout<<"enter the points on the cube:";cin>>x>>y>>z;cout<<"enter the size of the edge:";cin>>size;x1[0]=x1[3]=x;x1[1]=x1[2]=x+size;x1[4]=x1[7]=x;x1[5]=x1[6]=x+size;y1[0]=y1[1]=y;y1[2]=y1[3]=y+size;y1[4]=y1[5]=y;y1[6]=y1[7]=y+size;z1[1]=z1[2]=z1[3]=z1[0]=z ;z1[4]=z1[5]=z1[6]=z1[7]=z-size;for(i=0;i<8;i++){x2[i]=x1[i]+z1[i]/2;y2[i]=y1[i]+z1[i]/2;}cube c;getch();cleardevice();do{cout<<"menu"<<endl;cout<<"\n1.translation\n2.rotation\n3.scaling\n4.exit\n";cout<<"enter the choice:";cin>>ch;switch(ch){case 1:cout<<"enter the translation vector:";cin>>tx>>ty>>tz;for(i=0;i<8;i++){x3[i]=x1[i]+tx;y3[i]=y1[i]+ty;z3[i]=z1[i]+tz;}for(i=0;i<8;i++)
{x4[i]=x3[i]+z3[i]/2;y4[i]=y3[i]+z3[i]/2;}cleardevice();cout<<"before translation";c.drawcube(x2,y2);getch();cleardevice(); cout<<"after translation"; c.drawcube(x4,y4);getch();cleardevice();break;case 2:cout<<"enter the rotation angle:";cin>>theta;theta=(theta*3.14)/180;cout<<"enter the direction"<<endl;cout<<"1.rotation about x axis"<<endl<<"2.rotation about y axis"<<endl<<"3.rotation about z axis";cin>>op;if(op==1){for(i=0;i<8;i++)
To perform basic operation on images using Adobe Photoshop.
PROCEDURE:
Feathering:
Select the elliptical marques tool on duplicate Right click on area and select feather Set the feather radius.
Filtering:
From filtering menu select B From select radial Blue and motion Blue. Set the angle and distance. From filter menu, select liquefy which change the shape of flower. From filter menu, select distart and then select glass. Set distortion, smoothness and scaling for the object
Selection Tool:
This is used to select a portion of image and paste it in document.
Lasso Tool:
This is used to select the image in its shape.
Text Tool:
This is used to add text along with image.
Blur Tool:
This is used to change the image by its color, shape and dimension.
Painting Tool:
The powerful Photoshop paint engine lets you to simulate traditional painting technique
include charcoal, pastel and wet or dry brush effects.
Drawing Tool:
Draw resolution independent vector shapes instantly with the line, rectangle, ellipse,
polygon and custom shape tool.
Transformation Tools:
Scale, rotate, distor or skew engine easily. Apply the 3D transform filter to simulate 3D
effects such as tables and boxes. Using the liquefy command to interactively push, pull, bucker
or bloat an image
Sponge Tool:
The sponge tool subtly changes the color saturation of an area.in gray scale mode,the tool
increases or decreases contrast by moving gray level away from or towards the middle gray.
Marques tools:
The marques tools let you to select rectangle, ellipse, rounded rectangular and 1-pixel
rows and columns by default, a selection border is dragged from its corner.
Pen Tools:
The pen tools used in conjunction with the shape tools to create complex shapes.
RESULT: Thus the program is executed and verified.
3 dimensional transformation it has three axis x,y,z.Depandting upon there coordinate it will perform there Translation ,Rotaion,Scaling, The translation can be performed by changing the sign of the translation components Tx, Ty, and Tz.
3D TRANSFORMATION in c program computer graphics lab---------------------------------------------------1.Translation2.Rotation3.Scaling4.ExitEnter your Choice :1Enter the points 01: 288Enter the points 10: 288Enter the points 10: 258Enter the points 11: 288Enter the points 20: 258Enter the points 21: 258Enter the points 30: 288
// C++ program to draw and move a circle on the screen (up and down). when hit any key from the //keyboard circle will stop moving and program ends if you don't press any key from the keyboard circle //will move on the screen infinite times. Here in this program kbhit() function is//used. it checks for the keyboard keystroke.
while (!kbhit()){for (int i=1;i<=400; i++){circle(300,i,10);delay(10);cleardevice();}
for ( i=400;i>=1; i--){circle(300,i,10);delay(10);cleardevice();}
}
C++ program to generate concentric circles .
Here For loop will give radius (i) to circle function and each time it will increment by 5.Delay function will slow down the process to print the concentric circles on the screen. For initgraph() function and circle() function graphics.h header file is used the function initgraph() will convert text mode to graphics mode and closegraph() again converts graphics screen into text mode.In initgraph function third parameter is path of BGI files where graphics files are located. If the graphics driver files are other than this directory than type that path as a third parameter in initgraph() function. Many time we run a graphics program and often a BGI error occurres. It is related to this path of BGI files. Give correct path of BGI files in initgraph() function. If you don't know the path of BGI files then find *.BGI files by find option in winodws and you will be known the correct path.
Ex NO 9DATE: Drawing three dimensional objects and Scenes
AIM:To draw 3D objects and scenes
ALGORITHM:1. Parallel Projectiona) Enter the boundary coordinates of the object.b) Define the direction of the projection line.c) Align the projection plane so that it intersects each coordinate axis inwhich the object is defined at the same distance from the origin.d) The projection is perpendicular to the view planee) If the view plane is placed at position Z1 along the z axis , then anypoint (x,y,z) in viewing coordinates is transformed to projectioncoordinates xp=x and yp=y.2.Perspective Projectiona) Enter the boundary coordinates of the object.b) Define the projection reference point and thus the direction of theprojection lines.c) The projected view is obtained by transforming points along projectionlines that meet at the projection reference point.d) Calculate the intersection of the projection lines with the view plane.e) Parallel lines in the object that are not parallel to the plane areprojected into converging lines.f) Parallel lines that are parallel to the view plane will be projected asparallel lines.QUESTIONS1. What do you mean by Perspective projection?Perspective projection is one in which the lines of projection are not parallel. Instead,they all converge at a single point called the center of projection.2. What is Projection reference point?In Perspective projection, the lines of projection are not parallel. Instead, they allconverge at a single point called Projection reference point.3. What you mean by parallel projection?Parallel projection is one in which z coordinates is discarded and parallel lines fromeach vertex on the object are extended until they intersect the view plane.4. What is tweening?It is the process, which is applicable to animation objects defined by a sequence ofpoints, and that change shape from frame to frame.5.Define frame?One of the shape photographs that a film or video is made of is known asframe.6. What is key frame?One of the shape photographs that a film or video is made of the shape of an object isknown initially and for a small no of other frames called keyframe
of the displacement of the air pressure wave from its, or quiescent state.4. Define quantization (or) resolution?The resolution (or) quantization of a sample value depends on the number of bits usedin measuring the height of the waveform. An 8-bit quantization yields 256 possiblevalues, 16-bit CD-qudra quantization results in over 65536 values.5. What are the types of sound objects that can be used in multimedia production?There are four types of sound objects that can be used in multimedia production:_ Waveform audio_ MIDI sound tracks_ Compact disc (CD) audio_ MP3 files6.What are the applications of fractal image?Produces visual effect. Hence used in film industry
/*@@ program to translate rotate and scale an object in three dimention
@
*/
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#define degree 3.14/180
int xaxis,yaxis,zaxis;
int i,j,k;
/*@ function to multiply two matrix@
*/
int matrixmul(float **a,float **b,float **c,int n){