Computer Graphics
Graphic Systems
Input-Output Devices
Scan Conversion a line
Scan Conversion Circle
Scan Converting Ellipse
Filled Area Primitives
2D Transformations
2D-Viewing
Clipping Techniques
Pointing & Positioning
3D Computer Graphics
Hidden Surfaces
Projection
Programs
Computer Graphics Programs
Write a Program to draw basic graphics construction like line, circle, arc, ellipse and rectangle.
#include
#include
void main()
{
intgd=DETECT,gm;
initgraph (&gd,&gm,"c:\\tc\\bgi");
setbkcolor(GREEN);
printf("\t\t\t\n\nLINE");
line(50,40,190,40);
printf("\t\t\n\n\n\nRECTANGLE");
rectangle(125,115,215,165);
printf("\t\t\t\n\n\n\n\n\n\nARC");
arc(120,200,180,0,30);
printf("\t\n\n\n\nCIRCLE");
circle(120,270,30);
printf("\t\n\n\n\nECLIPSE");
ellipse(120,350,0,360,30,20);
getch();
}
#include
void main()
{
intgd=DETECT,gm;
initgraph (&gd,&gm,"c:\\tc\\bgi");
setbkcolor(GREEN);
printf("\t\t\t\n\nLINE");
line(50,40,190,40);
printf("\t\t\n\n\n\nRECTANGLE");
rectangle(125,115,215,165);
printf("\t\t\t\n\n\n\n\n\n\nARC");
arc(120,200,180,0,30);
printf("\t\n\n\n\nCIRCLE");
circle(120,270,30);
printf("\t\n\n\n\nECLIPSE");
ellipse(120,350,0,360,30,20);
getch();
}
Output
Write a Program to draw animation using increasing circles filled with different colors and patterns.
#include
#include
void main()
{
intgd=DETECT, gm, i, x, y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x=getmaxx()/3;
y=getmaxx()/3;
setbkcolor(WHITE);
setcolor(BLUE);
for(i=1;i<=8;i++)
{
setfillstyle(i,i);
delay(20);
circle(x, y, i*20);
floodfill(x-2+i*20,y,BLUE);
}
getch();
closegraph();
}
Output
#include
void main()
{
intgd=DETECT, gm, i, x, y;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x=getmaxx()/3;
y=getmaxx()/3;
setbkcolor(WHITE);
setcolor(BLUE);
for(i=1;i<=8;i++)
{
setfillstyle(i,i);
delay(20);
circle(x, y, i*20);
floodfill(x-2+i*20,y,BLUE);
}
getch();
closegraph();
}
Output
Output
Program to make screen saver in that display different size circles filled with different colors and at random places.
#include
#include
#include"graphics.h"
#include"stdlib.h"
void main()
{
intgd=DETECT,gm,i=0,x,xx,y,yy,r;
//Initializes the graphics system
initgraph(&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
while(!kbhit())
{
i++;
// setfillstyle(random(i),random(30));
circle(xx=random(x),yy=random(y),random(30));
setfillstyle(random(i),random(30));
floodfill(xx,yy,getmaxcolor());
delay(200);
}
getch();
}
#include
#include"graphics.h"
#include"stdlib.h"
void main()
{
intgd=DETECT,gm,i=0,x,xx,y,yy,r;
//Initializes the graphics system
initgraph(&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
while(!kbhit())
{
i++;
// setfillstyle(random(i),random(30));
circle(xx=random(x),yy=random(y),random(30));
setfillstyle(random(i),random(30));
floodfill(xx,yy,getmaxcolor());
delay(200);
}
getch();
}
Output
5.6M
921
Polymorphism in Java | Dynamic Method Dispatch
Write a Program to make a moving colored car using inbuilt functions.
#include
#include
int main()
{
intgd=DETECT,gm, i, maxx, cy;
initgraph(&gd, &gm, "C:\\TC\\BGI");
setbkcolor(WHITE);
setcolor(RED);
maxx = getmaxx();
cy = getmaxy()/2;
for(i=0;i
{
cleardevice();
line(0+i,cy-20, 0+i, cy+15);
line(0+i, cy-20, 25+i, cy-20);
line(25+i, cy-20, 40+i, cy-70);
line(40+i, cy-70, 100+i, cy-70);
line(100+i, cy-70, 115+i, cy-20);
line(115+i, cy-20, 140+i, cy-20);
line(0+i, cy+15, 18+i, cy+15);
circle(28+i, cy+15, 10);
line(38+i, cy+15, 102+i, cy+15);
circle(112+i, cy+15,10);
line(122+i, cy+15 ,140+i,cy+15);
line(140+i, cy+15, 140+i, cy-20);
rectangle(50+i, cy-62, 90+i, cy-30);
setfillstyle(1,BLUE);
floodfill(5+i, cy-15, RED);
setfillstyle(1, LIGHTBLUE);
floodfill(52+i, cy-60, RED);
delay(10);
}
getch();
closegraph();
return 0;
}
#include
int main()
{
intgd=DETECT,gm, i, maxx, cy;
initgraph(&gd, &gm, "C:\\TC\\BGI");
setbkcolor(WHITE);
setcolor(RED);
maxx = getmaxx();
cy = getmaxy()/2;
for(i=0;i
{
cleardevice();
line(0+i,cy-20, 0+i, cy+15);
line(0+i, cy-20, 25+i, cy-20);
line(25+i, cy-20, 40+i, cy-70);
line(40+i, cy-70, 100+i, cy-70);
line(100+i, cy-70, 115+i, cy-20);
line(115+i, cy-20, 140+i, cy-20);
line(0+i, cy+15, 18+i, cy+15);
circle(28+i, cy+15, 10);
line(38+i, cy+15, 102+i, cy+15);
circle(112+i, cy+15,10);
line(122+i, cy+15 ,140+i,cy+15);
line(140+i, cy+15, 140+i, cy-20);
rectangle(50+i, cy-62, 90+i, cy-30);
setfillstyle(1,BLUE);
floodfill(5+i, cy-15, RED);
setfillstyle(1, LIGHTBLUE);
floodfill(52+i, cy-60, RED);
delay(10);
}
getch();
closegraph();
return 0;
}
Output
Write a Program to print your name in Hindi script on console output in C.
#include
#include
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(9);
line(100,100,370,100);
line(120,100,120,170);
arc(143,100,0,180,23);
line(165,100,165,155);
arc(150,155,100,0,15);
line(180,100,180,170);
circle(210,140,10);
line(210,130,250,130);
circle(280,140,10);
line(280,130,330,130);
line(330,100,330,170);
line(345,100,345,170);
ellipse(337,100,0,180,9,18);
getch();
}
#include
#include
#include
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(9);
line(100,100,370,100);
line(120,100,120,170);
arc(143,100,0,180,23);
line(165,100,165,155);
arc(150,155,100,0,15);
line(180,100,180,170);
circle(210,140,10);
line(210,130,250,130);
circle(280,140,10);
line(280,130,330,130);
line(330,100,330,170);
line(345,100,345,170);
ellipse(337,100,0,180,9,18);
getch();
}
Output
Write a Program control a ball using arrow keys.
#include
#include
void main()
{
intgd=DETECT,gm,x,y,r=40;
charch;
initgraph(&gd,&gm,"C:/TURBOC3/BGI");
setbkcolor(3);
x=getmaxx()/2;
y=getmaxy()/2;
setfillstyle(1,RED);
circle(x,y,r);
floodfill(x,y,getmaxcolor());
while((ch=getch())!=13)
{
switch(ch)
{
case 75: if(x>=r+1)
{
cleardevice();
circle(x-=10,y,r);
floodfill(x,y,getmaxcolor());
}
break;
case 72: if(y>=r+1)
{
cleardevice();
circle(x,y-=10,r);
floodfill(x,y,getmaxcolor());
}
break;
case 77: if(x<=(getmaxx()-r-10))
{
cleardevice();
circle(x+=10,y,r);
floodfill(x,y,getmaxcolor());
}
break;
case 80: if(y<=(getmaxy()-r-10))
{
cleardevice();
circle(x,y+=10,r);
floodfill(x,y,getmaxcolor());
}
}
}
getch();
}
#include
void main()
{
intgd=DETECT,gm,x,y,r=40;
charch;
initgraph(&gd,&gm,"C:/TURBOC3/BGI");
setbkcolor(3);
x=getmaxx()/2;
y=getmaxy()/2;
setfillstyle(1,RED);
circle(x,y,r);
floodfill(x,y,getmaxcolor());
while((ch=getch())!=13)
{
switch(ch)
{
case 75: if(x>=r+1)
{
cleardevice();
circle(x-=10,y,r);
floodfill(x,y,getmaxcolor());
}
break;
case 72: if(y>=r+1)
{
cleardevice();
circle(x,y-=10,r);
floodfill(x,y,getmaxcolor());
}
break;
case 77: if(x<=(getmaxx()-r-10))
{
cleardevice();
circle(x+=10,y,r);
floodfill(x,y,getmaxcolor());
}
break;
case 80: if(y<=(getmaxy()-r-10))
{
cleardevice();
circle(x,y+=10,r);
floodfill(x,y,getmaxcolor());
}
}
}
getch();
}
Output
Write a Program to implement Digital Clock.
-
#include
#include
#include
#include
struct time t;
void display(int,int,int);
void main()
{
int i=0,gd=DETECT,gm,hr,min,sec;
clrscr();
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
setcolor(GREEN);
settextstyle(4,0,7);
while(!kbhit())
{
gettime(&t);
hr=t.ti_hour;
min=t.ti_min;
sec=t.ti_sec;
i++;
display(100,100,hr);
display(200,100,min);
display(300,100,sec);
sound(400);
delay(30);
nosound();
delay(930);
cleardevice();
}
getch();
}
void display(int x,int y,int num)
{
char str[3];
itoa(num,str,10);
settextstyle(4,0,7);
outtextxy(180,100,":");
outtextxy(280,100,":");
outtextxy(x,y,str);
rectangle(90,90,380,200);
rectangle(70,70,400,220);
outtextxy(90,250,"Digital Clock");
}
Output
Write a Program to make puzzle game.
-
#include
#include
#include
#include
#include
int a[5][5];
int t[16]={0,4,11,12,7,1,15,5,13,6,10,3,2,14,8,9};
int test[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
struct pos
{
int h,v;
}
p[4][4];
int row=4,col=4;
void game(int); //MOVEMENT
void rec(); //DRAWING RECTANGLE
void pri(); //PRINTING NUMBERS INITIALLY
int getkey(); // TO TRACE KEY PRESSED
inline void space()
{
cout<<"";
}
inline void print(int r,int c)
{
cout<
}
void init(); //TO STORE CO-ORDINATES
int stop(); // STOPING CRITERION
void gopr(int,int); //TO PRINT NUMBER IN GAME
void main()
{
int gm=DETECT,gd=DETECT;
initgraph(&gm,&gd,"c:\\turboc3\\bgi");
int d,cr=1;
init();
rec();
print();
while(cr!=16)
{
d=getkey();
game(d);
cr=stop();
}
settextstyle(10,0,1);
outtextxy(400,300,"You are winner!");
getch();
}
void rec()
{
setcolor(5);
for(int i=0;i<200;i+=50)
{
for(int j=0;j<240;j+=60)
rectangle(j+100,i+100,j+50,i+60);
}
}
void pri()
{
int k=1;
for(int x=0,i=6;x<4;x++,i+=3)
{
for(int y=0,j=10;y<4&&k<16;y++,j+=7,k++)
{
gotoxy(p[x][y].h,p[x][y].v);
cout<
}
}
}
int getkey()
{
union REGS i,o;
while(!kbhit());
i.h.ah=0;
int86(22,&i,&o);
return(o.h.ah);
}
void init()
{
int k=1;
for(int x=0,i=6;x<4;x++,i+=3)
{
for(int y=0,j=10;y<4;y++,j+=7)
{
p[x][y].h=j;
p[x][y].v=i;
a[x][y]=t[k++];
}
}
}
void game(int s)
{
int r=row-1;
int c=col-1;
if(s==77 &&c!=0) //right
{
col--;
a[r][c]=a[r][c-1];
gopr(r,c-1);
space();
gopr(r,c);
print(r,c-1);
}
if(s==80 && r!=0) //down
{
row--;
a[r][c]=a[r-1][c];
gopr(r-1,c);
space();
gopr(r,c);
print(r-1,c);
}
if(s==75 && c!=3) //left
{
a[r][c]=a[r][c+1];
col++;
gopr(r,c+1);
space();
gopr(r,c);
print(r,c+1);
}
if(s==72 &&r!=3) //up
{
a[r][c]=a[r+1][c];
row++;
gopr(r+1,c);
space();
gopr(r,c);
print(r+1,c);
}
}
void gopr(int x, int y)
{
gotoxy(p[x][y].h,p[x][y].v);
}
int stop()
{
int k=0,d=1;
for(int x=0;x<4;x++)
{
for(int y=0;y<4;y++)
{
if(a[x][y]==test[k])
d++;
k++;
}
}
return d;
}
Output
Write a Program to implement bouncing ball using sine wave form.
-
#include
#include
#define HEIGHT getmaxy()
#define WIDTH getmaxx()
#define GROUND 450
#define MAXHEIGHT 420
void main()
{
int x,y=0,t=MAXHEIGHT,c=1;
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\T urboC3\\BGI");
for(x=40;x<=getmaxx();x=x+2)
{
//Draw Ground
rectangle (0,MAXHEIGHT,getmaxx(),MAXHEIGHT+5);
floodfill (5,MAXHEIGHT+3,WHITE);
//Draw Ball
pieslice(x,y,0,360,20);
//floodfill(x,y,RED);
delay(100);
if(y>MAXHEIGHT-20)
{
c=0;
t=t-40;
}
if(y<=(MAXHEIGHT-t))
{
c=1;
}
if(t>=40)
y=y+(c? 15:-15);
cleardevice();
//Exit upon keypress
if(kbhit())
break;
}
getch();
}
Output
Write a Program to implement Bouncing Ball in vertical direction.
-
#include
#include
#include
#include
int main()
{
int gd = DETECT, gm;
int i, x, y, flag=0;
initgraph(&gd, &gm, "C:\\TC\\BGI");
x = getmaxx()/2;
y = 30;
while (!kbhit())
{
if(y >= getmaxy()-30 || y <= 30)
flag = !flag;
/* draws the gray board */
setcolor(RED);
setfillstyle(SOLID_FILL, RED);
circle(x, y, 30);
floodfill(x, y, RED);
delay(50);
cleardevice();
if(flag)
{
y = y + 5;
}
else
{
y = y - 5;
}
}
getch();
closegraph();
return 0;
}
Output
Write a program of Translation, Rotation, and Scaling using Composite Transformation.
-
#include
#include
#include
#include
int x1,y1,x2,y2,x3,y3,a,b;
void draw();
void rotate();
int main(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("Enter first co-ordinate value for triangle:");
scanf("%d%d",&x1,&y1);
printf("Enter second co-ordinatevalues for triangle:");
scanf("%d%d",&x2,&y2);
printf("Enter third co-ordinate valuesfor triangle:");
scanf("%d%d",&x3,&y3);
draw();
getch();
rotate();
getch();
return 0;
}
void draw()
{
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
}
void rotate()
{
int a1,a2,a3,b1,b2,b3;
float angle;
printf("Enter the rotation angle co-ordinates:");
scanf("%f",&angle);
cleardevice();
angle=(angle*3.14)/180;
a1=a+(x1-a)*cos(angle)-(y1-b)*sin(angle);
b1=b+(x1-a)*sin(angle)+(y2-b)*cos(angle);
a2=a+(x2-a)*cos(angle)-(y1-b)*sin(angle);
b2=b+(x2-a)*sin(angle)+(y2-b)*cos(angle);
a3=a+(x3-a)*cos(angle)-(y1-b)*sin(angle);
b3=b+(x3-a)*sin(angle)+(y2-b)*cos(angle);
printf("ROTATION");
printf("\n Changed coordinates\n");
printf("%d %d\n%d %d\n%d %d",a1,b1,a2,b2,a3,b3);
line(a1,b1,a2,b2);
line(a2,b2,a3,b3);
line(a3,b3,a1,b1);
}
Output
Write a program to draw a Circle using midpoint implementation Method.
-
#include
#include
void drawcircle(int x0, int y0, int radius)
{
int x = radius;
int y = 0;
int err = 0;
while (x >= y)
{
putpixel(x0 + x, y0 + y, 7);
putpixel(x0 + y, y0 + x, 7);
putpixel(x0 - y, y0 + x, 7);
putpixel(x0 - x, y0 + y, 7);
putpixel(x0 - x, y0 - y, 7);
putpixel(x0 - y, y0 - x, 7);
putpixel(x0 + y, y0 - x, 7);
putpixel(x0 + x, y0 - y, 7);
if (err <= 0)
{
y += 1;
err += 2*y + 1;
}
if (err > 0)
{
x -= 1;
err -= 2*x + 1;
}
}
}
void main()
{
int gdriver=DETECT, gmode, error, x, y, r;
initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
printf("Enter radius of circle: ");
scanf("%d", &r);
printf("Enter co-ordinates of center(x and y): ");
scanf("%d%d", &x, &y);
drawcircle(x, y, r);
getch();
}
Output
Write a program to draw Bezier curve.
-
#include
#include
#include
#include
void bezier (int x[4], int y[4])
{
int gd = DETECT, gm;
int i;
double t;
initgraph (&gd, &gm, "C:\\tc\\bgi");
for (t = 0.0; t < 1.0; t += 0.0005)
{
double xt = pow (1-t, 3) * x[0] + 3 * t * pow (1-t, 2) * x[1] +
3 * pow (t, 2) * (1-t) * x[2] + pow (t, 3) * x[3];
double yt = pow (1-t, 3) * y[0] + 3 * t * pow (1-t, 2) * y[1] +
3 * pow (t, 2) * (1-t) * y[2] + pow (t, 3) * y[3];
putpixel (xt, yt, WHITE);
}
for (i=0; i<4; i++)
putpixel (x[i], y[i], YELLOW);
getch();
closegraph();
return;
}
void main()
{
int x[4], y[4];
int i;
printf ("Enter the x- and y-coordinates of the four control points.\n");
for (i=0; i<4; i++)
scanf ("%d%d", &x[i], &y[i]);
bezier (x, y);
}
Output
Program to rotate a rectangle about its midpoint
-
#include
#include
#include
#include
#include
#define pi 3.14
class arc
{
float x[10], y[10], theta, h1, k1,r[0][10],ang;
float p[10][10],p1[10][10],x1[10], y1[10],xm,yx;
int i, k, j, n;
public:
void get();
void cal();
void map();
void graph();
void plot();
void plot1();
};
void arc::get()
{
cout "<<"\n ENTER ANGLE OF ROTATION ";
cin>>ang;
n = 4;
cout<<"\n ENTER";
for (i=0; i
{
cout<<"\n x["
cin>>x[i]>>y[i];
}
h1=x [0] + (([1]-x[0])/2);
k1=y[0]+(([3]-y[0])/2);
cout<<"\n MIDPOINT OF RECTANGLE IS--"<
theta=(ang*pi)/180?;
r[0][0]=cos (theta);
r[0][1]= -sin?(theta);
r[0][2]=(-h1*cos(theta))+(k1*sin(theta)+h1;
r[1][0]=sin (theta);
r [1][1]=cos (theta);
r [1][2]=(-h1*sin(theta))+(-k1*cos(theta)+k1;
r[2][0]=0;
r[2][1]=0;
r[2][2]=1;
}
void arc ::cal()
{
for(i=0;i
{
p[0][i]=x[i];
p[1][i]=y[i];
p[2][i]=1;
}
for(i=0;i<3;i++)
{
for(j=0;j
{
p1[i][j]=0;
for (k=0;k<3;k++)
{
p1[i][j]+=r[i][k]*p[k][j];
}
}
}
for(i=0;i
{
x1[i]=p1[0][i];
y1[i]=p[1][i];
}
}
void arc::map()
{
int gd=DETECT, gm;
initgraph (&gd, &gm, "");
int errorcode = graphresult();
/*an error occurred */
if (errorcode!=grOK)
{
printf("Graphics error: %s \n",grapherrormsg (errorcode));
printf("Press and key to halt: ");
getch();
exit(1); /* terminate with an error code */
}
}
void arc::graph()
{
xm=getmaxx()/2;
ym=getmaxy()/2;
line (xm, 0, xm, 2 * ym);
line (0, ym, 2 * xm, ym);
}
void arc :: plot 1()
{
for (i=0;i
{
circle (x1[i]+xm, (-y1[i]+ym), 2);
line (x1[i]+xm, (-y1[i]+ym), x[i+1] xm, (-y1[0]+ym));
}
line (x1[n-1] +xm, (-y1[n-1]+ym), x1[0]+xm, (-y1[0]+ym));
getch();
}
void arc :: plot ()
{
for (i=0;i
{
circle (x[i]+xm, (-y[i]+ym), 2);
line (x[i]+xm, (-y[i]+ym), x[i+1] xm, (-y[i+1]+ym));
}
circle (x[n-1]+xm, (-y[n-1]+ym),2);
line (x[n-1]+xm, (-y[n-1]+ym), x[0]+xm, (-y[0]+ym));
getch();
}
void main ()
{
class arc a;
clrscr();
a.map();
a.graph();
a.get();
a.cal();
a.plot();
a.plot1();
getch();
}
Output
Program to clip a line using Liang Barsky Method
#include
#include
#include
#include
#include
class liang
{
float x1,x2,y1,y2,u1,u2,dx,dy,xm,ym;
float xmin, ymin, xmax, ymax,p[4],q[4],r[5],r[5];
int gd, gm, test, s, k;
public:
void clipliang();
void get();
void map();
void graph();
};
void liang :: map()
{
gd=DETECT;
initgraph (&gd, &gm, "");
int errorcode = graphresult();
/*an error occurred */
if (errorcode!=grOK)
{
printf("Graphics error: %s \n",grapherrormsg (errorcode));
printf("Press and key to halt: ");
getch();
exit(1); /* terminate with an error code */
}
}
void liang::graph()
{
xm=getmaxx()/2;
ym=getmaxy()/2;
line (xm, 0, xm, 2 * ym);
line (0, ym, 2 * xm, ym);
}
void liang :: get()
{
cout<<"\n ENTER WINDOW COORDINATES xwmin, ywmin, xwmax, ywmax";
cin>>xmin>>ymin>>xmax>>ymax>>;
rectangle (xmin+xm,-ymin+ym,xmax+xm, -ymax+ym);
// rectangle (320+xwmin, 240-ywmax, 320+xwmax, 240-ywmin);
cout<<"\n ENTER END POINTS OF LINE (x1, y1)(x2, y2) ";
cin>>x1>>y1>>x2>>y2;
line (x1+xm,-y1+ym, x2+xm,-y2+ym);
getch();
}
// line (x1, y1, x2, y2);
void liang :: clipliang()
{
float x=0, y=1;
dx=x2-x1;
dy=y2-y1;
p[0]=-dx;
p[1]=dx;
p[2]=-dy;
p[3]=dy;
q[0]=x1-xmin;
q[1]=xmax-x1;
q[2]=y1-ymin;
q[3]=ymax-y1;
&
#include
#include
#include
#include
class liang
{
float x1,x2,y1,y2,u1,u2,dx,dy,xm,ym;
float xmin, ymin, xmax, ymax,p[4],q[4],r[5],r[5];
int gd, gm, test, s, k;
public:
void clipliang();
void get();
void map();
void graph();
};
void liang :: map()
{
gd=DETECT;
initgraph (&gd, &gm, "");
int errorcode = graphresult();
/*an error occurred */
if (errorcode!=grOK)
{
printf("Graphics error: %s \n",grapherrormsg (errorcode));
printf("Press and key to halt: ");
getch();
exit(1); /* terminate with an error code */
}
}
void liang::graph()
{
xm=getmaxx()/2;
ym=getmaxy()/2;
line (xm, 0, xm, 2 * ym);
line (0, ym, 2 * xm, ym);
}
void liang :: get()
{
cout<<"\n ENTER WINDOW COORDINATES xwmin, ywmin, xwmax, ywmax";
cin>>xmin>>ymin>>xmax>>ymax>>;
rectangle (xmin+xm,-ymin+ym,xmax+xm, -ymax+ym);
// rectangle (320+xwmin, 240-ywmax, 320+xwmax, 240-ywmin);
cout<<"\n ENTER END POINTS OF LINE (x1, y1)(x2, y2) ";
cin>>x1>>y1>>x2>>y2;
line (x1+xm,-y1+ym, x2+xm,-y2+ym);
getch();
}
// line (x1, y1, x2, y2);
void liang :: clipliang()
{
float x=0, y=1;
dx=x2-x1;
dy=y2-y1;
p[0]=-dx;
p[1]=dx;
p[2]=-dy;
p[3]=dy;
q[0]=x1-xmin;
q[1]=xmax-x1;
q[2]=y1-ymin;
q[3]=ymax-y1;
&