Assignment 2 NAME-Rutik Kishor Rokade Roll No - 205B060: Program
Assignment 2 NAME-Rutik Kishor Rokade Roll No - 205B060: Program
PROGRAM:
#include<conio.h>
#include<iostream>
#include<graphics.h>
int code = 0;
return code;
int main()
initgraph(&gdriver,&gmode," ");
setcolor(WHITE);
cin>>xmin>>ymin>>xmax>>ymax;
rectangle(xmin,ymin,xmax,ymax);
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
line(x1,y1,x2,y2);
getch();
while(1){
float m =(float)(y2-y1)/(x2-x1);
accept = 1;
break;
break;
else
int x,y;
int temp;
if(outcode1==0)
temp = outcode2;
else
temp = outcode1;
y = ymax;
x = x1+ (ymin-y1)/m;
y = ymin;
x = xmin;
y = y1+ m*(xmin-x1);
x = xmax;
y = y1+ m*(xmax-x1);
//Check which point we had selected earlier as temp, and replace its co-ordinates
if(temp == outcode1){
x1 = x;
y1 = y;
outcode1 = getcode(x1,y1);
}else{
x2 = x;
y2 = y;
outcode2 = getcode(x2,y2);
cout<<"After clipping:";
if(accept)
cleardevice();
rectangle(xmin,ymin,xmax,ymax);
setcolor(RED);
line(x1,y1,x2,y2);
getch();
closegraph();
INPUT:
50
20
40
55
77
--------------------------------