diff --git a/Answers/CG1_output.JPG b/Answers/CG1_output.JPG new file mode 100644 index 0000000..0095e07 Binary files /dev/null and b/Answers/CG1_output.JPG differ diff --git a/Answers/CG2_output.JPG b/Answers/CG2_output.JPG new file mode 100644 index 0000000..b30916b Binary files /dev/null and b/Answers/CG2_output.JPG differ diff --git a/Answers/Saurabh_Bagouli_code1 b/Answers/Saurabh_Bagouli_code1 new file mode 100644 index 0000000..b1fa068 --- /dev/null +++ b/Answers/Saurabh_Bagouli_code1 @@ -0,0 +1,39 @@ +PROGRAM 1: Write a program to scale a triangle about origin. + +#include +#include +#include +void scaling(int x1,int y1,int x2,int y2,int x3,int y3){ +int sx,sy,xn1,yn1,xn2,xn3,yn3,yn2,gd=0,gm; +printf("enter the scaling vector\n"); +scanf("%d%d",&sx,&sy); +xn1=x1*sx; +yn1=y1*sy; +xn2=x2*sx; +yn2=y2*sy; +xn3=x3*sx; +yn3=y3*sy; +initgraph(&gd,&gm,""); +setcolor(RED); +line(x1,y1,x2,y2); +setcolor(RED); +line(x1,y1,x3,y3); +setcolor(RED); +line(x2,y2,x3,y3); +delay(600); +setcolor(YELLOW); +line(xn1,yn1,xn2,yn2); +setcolor(YELLOW); +line(xn1,yn1,xn3,yn3); +setcolor(YELLOW); +line(xn2,yn2,xn3,yn3); +delay(600); +} +int main( ){ +int ch,x1,y1,x2,y2,x3,y3; +printf("enter the vertex co-ordinates of triangle\n"); +scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3); +scaling(x1,y1,x2,y2,x3,y3); +delay(9999); +return 0; +} diff --git a/Answers/Saurabh_Bagouli_code2 b/Answers/Saurabh_Bagouli_code2 new file mode 100644 index 0000000..c3a5452 --- /dev/null +++ b/Answers/Saurabh_Bagouli_code2 @@ -0,0 +1,30 @@ +#include +void main( ){ +float x,y,x1,y1,x2,y2,dx,dy,steps; +int i,gd=DETECT,gm; +printf("Enter (x1, y1) : "); +scanf("%f%f",&x1,&y1); +printf("Enter (x2,y2): "); +scanf("%f%f",&x2,&y2); +initgraph(&gd,&gm,""); +dx=abs(x2-x1); +dy=abs(y2-y1); +if(dx>=dy) +steps=dx; +else +steps=dy; +dx=dx/steps; +dy=dy/steps; +x=x1; +y=y1; +i=1; +while(i<=steps){ +putpixel(x,y,5); +x=x+dx; +y=y+dy; +i=i+1; +delay(50); +} +delay(5000); +closegraph( ); +}