// A program for draw a line.
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int
x1,x2,y1,y2,y3;
int
gdriver,gmode;
gdriver=DETECT;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
char
msg[5];
gotoxy(18,25);
cout<<"By
Computer Science & Engineering Students)";
cout<<"\n\t\t\tGuided
BY - Shiv Shakti Sir";
gotoxy(1,0);
gotoxy(20,1);
cout<<"******************
LINE ******************\n"<<endl;
cout<<"Starting
pixel cordinate : ";
cin>>x1>>y1;
cout<<"Ending
pixel cordinate : ";
cin>>x2>>y2;
y3=y2;
line(x1,y1,x2,y2);
sprintf(msg,"
(%d,%d)", x1, y1);
outtextxy(x1,y1,msg);
sprintf(msg,"
(%d,%d)", x2, y3);
outtextxy(x2,y3,msg);
getch();
closegraph();
}
// A program for draw rectangle.
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
void main()
{
int
x1,y1,width,length;
int
gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
setbkcolor(1);
setcolor(4);
char
msg[5];
gotoxy(18,25);
cout<<"By
Computer Science & Engineering Students)";
cout<<"\n\t\t\tGuided
BY - Shiv Shakti Sir";
gotoxy(1,0);
gotoxy(16,1);
cout<<"******************
RECTANGLE ******************\n"<<endl;
cout<<"Sarting
cordinate : ";
cin>>x1>>y1;
cout<<"Put
the length(in pixel) : ";
cin>>length;
cout<<"Put
the width(in pixel) : ";
cin>>width;
line(x1,y1,x1+length,y1);
line(x1+length,y1,x1+length,y1+width);
line(x1+length,y1+width,x1,y1+width);
line(x1,y1+width,x1,y1);
getch();
closegraph();
}
// Ex: starting point (170,120), length (300), width (100).
No comments:
Post a Comment