//Line Clipping
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x1,y1,x2,y2;
int a1,b1,c1,d1;
int a2,b2,c2,d2;
int a3,b3,c3,d3;
int x,y;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
x=getmaxx();y=getmaxy();
printf("Enter the starting coordinates of rectangle\n");
scanf("%d%d",&x1,&y1);
printf("Enter the end coordinates of rectangle\n");
scanf("%d%d",&x2,&y2);
rectangle(x1,y1,x2,y2);
printf("Enter the start and end coordinates for 1st line\n");
scanf("%d%d%d%d",&a1,&b1,&c1,&d1);
printf("Enter the start and end coordinates for 2nd line\n");
scanf("%d%d%d%d",&a2,&b2,&c2,&d2);
printf("Enter the start and end coordinates for 3rd line\n");
scanf("%d%d%d%d",&a3,&b3,&c3,&d3);
line(a1,b1,c1,d1);
line(a2,b2,c2,d2);
line(a3,b3,c3,d3);
getch();
setfillstyle(1,BLACK);
bar(0,0,x,y1-1);
bar(0,0,x1-1,y);
bar(x2+1,0,x,y);
bar(0,y2+1,x,y);
getch();
closegraph();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.