C Program for Region Code (Cohen Sutherland Line Clipping Algorithm)

Program /* This program is all about to show only the region code of the line drawn as inputted coordinate. The region code is on the b...

Program

/*
This program is all about to show only the region code of the line drawn as inputted coordinate.
The region code is on the basis of Cohen Sutherland Line Clipping Algorithm.
If the end point of the line drawn lies inside window  i.e the rectangle the region code is 0000.
If left of the window region code is 0001.
If right of the window region code is 0010.
If bottom of the window region code is 0100.
If top of the window region code is 1000.
If left-top of the window region code is 1001.
If left-bottom of the window region code is 0101.
If right-top of the window region code is 1010.
If right-bottom of the window region code is 0110.
According to the algorithm the line is clipped only the portion lies inside the window.

Visit  daily for updates....
Thank You!!!
*/


#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void check(int,int);
void main()
{
 int gd=DETECT,gm,x1,x2,y1,y2;
 clrscr();
 initgraph(&gd,&gm,"..\\bgi");
 line(100,0,100,getmaxy());
 line(getmaxx()-100,0,getmaxx()-100,getmaxy());
 line(0,100,getmaxx(),100);
 line(0,getmaxy()-100,getmaxx(),getmaxy()-100);
// outtextxy(getmaxx()/2,getmaxy()/2,"0000");
 printf("Program to show region code of two end point of line\nCohen Sutherland Line Clipping Algorithm\n");
 printf("Enter coordinates x1,y1,x2,y2 to draw line\n");
 scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
 line(x1,y1,x2,y2);
 check(x1,y1);
 check(x2,y2);
 getch();
}

void check(int x,int y)
{
settextstyle(2,0,0);


if(x<100 && y<100)
outtextxy(x,y,"1001");

else if(x>getmaxx()-100 && y<100)
outtextxy(x,y,"1010");

else if(x<100 && y>getmaxy()-100)
outtextxy(x,y,"0101");

else if(x>getmaxx()-100  && y>getmaxy()-100)
outtextxy(x,y,"0110");

else if(x<100 && y>=100 && y<=getmaxy()-100)
outtextxy(x,y,"0001");

else if(x>getmaxx()-100 && y>=100 && y<=getmaxy()-100)
outtextxy(x,y,"0010");

else if(x>=100 && x<getmaxx()-100 && y<100)
outtextxy(x,y,"1000");

else if(x>=100 && x<getmaxx()-100 && y>getmaxy()-100)
outtextxy(x,y,"0100");

else
outtextxy(x,y,"0000");
}

Output















COMMENTS

Name

Accident Alert,1,AI,2,Array,1,Aurdino,1,C,2,Computer Graphics,9,Data Science,3,Dataset,1,Decoratot,1,Django,1,ESP32,1,Fixed point/iteration method,1,Greater or smaller,1,html,1,Image Processing,1,JAVA,1,Javascript,22,Machine Learning,1,Matlab,3,Numerical Method,13,OOP,1,Other,3,PHP,1,Point operation,1,Python,11,Raspberry pi,1,Recommendation System,1,Regression,1,Reservation System,1,Robotics,1,Simulation,2,sine wave,1,String Handling Function,1,Web scrap,1,Webpage,1,
ltr
item
COMPUTER PROGRAMMING: C Program for Region Code (Cohen Sutherland Line Clipping Algorithm)
C Program for Region Code (Cohen Sutherland Line Clipping Algorithm)
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidzg5mm36QExe9tmcRXc4F-M00QQkpu5sVxscMCB_9u2Twp8ooe9z4TqbLQjQpjP34-cX1Jt_PMY2Fkl4vmV1q9Y7UNk6OimGYwSzJFYYGKRufaok-lZ-7f6plpTkm-XbMCmZJjj8jUMac/s640/d.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidzg5mm36QExe9tmcRXc4F-M00QQkpu5sVxscMCB_9u2Twp8ooe9z4TqbLQjQpjP34-cX1Jt_PMY2Fkl4vmV1q9Y7UNk6OimGYwSzJFYYGKRufaok-lZ-7f6plpTkm-XbMCmZJjj8jUMac/s72-c/d.png
COMPUTER PROGRAMMING
https://computerprogram4ru.blogspot.com/2017/10/c-program-for-region-code-cohen.html
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/2017/10/c-program-for-region-code-cohen.html
true
8672391763020279633
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy