123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
A Simple 2D-Drawing Program

--------------------------------------------------------------------------------

Description : This is an Simple 2d drawing program in C. It provides some basic functions for graphics in DOS and is a fun to use.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define ESC 0x1b
void drcir(int,int,int);
void drarc(int,int,int);
void main()
{
int a,b,c,d,e,f,curcolor=3;
int gdriver = DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\tc\bgi");
verybegin:
sound(333);
delay(100);
sound(222);
delay(100);
sound(250);
delay(100);
sound(33);
delay(100);
sound(111);
delay(100);
sound(222);
delay(100);
sound(333);
delay(100);
sound(3333);
delay(100);
nosound();
gotoxy(25,1);
printf("2d Drawing");
gotoxy(18,5);
printf("A Simple Program");
gotoxy(18,6);
printf("This is used for drawing circles,arcs,rectangle,");
gotoxy(18,7);
printf("lines and many more...");
printf("

The Controls For The Two-Dimensional Drawing

<BR>);
printf(" N(Up Arrow) = North<BR>);
printf(" S(Down Arrow) = South<BR>);
printf(" E(Right Arrow) = East<BR>);
printf(" W(Left Arrow) = West<BR>);
printf(" F(Page Up) = North-East<BR>);
printf(" X(Home) = North-West<BR>);
printf(" D(Page Down) = South-East<BR>);
printf(" Z(End) = South-West<BR>);
printf(" J = Current Position<BR>);
printf(" B = Help(This Screen)<BR>);
printf(" R(Insert) = Reset<BR>);
printf(" T = Color Change(0-9)<BR>);
printf(" C = Circle<BR>);
printf(" A = Arc<BR>);
printf(" ESC = Quit<BR>);
getch();
begin:
curcolor=3;
a = getmaxx() / 2;
b = getmaxy() / 2;
cleardevice();
start:
putpixel(a,b,curcolor);
c=getch();
sound(100);
delay(20);
nosound();
if(c==ESC)
{
goto end;
}
switch(c)
{
case 'N':
case 'n':
case 'H':
case 'h':
c=a;
d=b-1;
a=c;
b=d;
goto start;
case 'S':
case 's':
case 'P':
case 'p':
c=a;
d=b+1;
a=c;
b=d;
goto start;
case 'E':
case 'e':
case 'M':
case 'm':
c=a+1;
d=b;
a=c;
b=d;
goto start;
case 'W':
case 'w':
case 'K':
case 'k':
c=a-1;
d=b;
a=c;
b=d;
goto start;
case 'D':
case 'd':
case 'Q':
case 'q':
c=a+1;
d=b+1;
a=c;
b=d;
goto start;
case 'X':
case 'x':
case 'G':
case 'g':
c=a-1;
d=b-1;
a=c;
b=d;
goto start;
case 'Z':
case 'z':
case 'O':
case 'o':
c=a-1;
d=b+1;
a=c;
b=d;
goto start;
case 'F':
case 'f':
case 'I':
case 'i':
c=a+1;
d=b-1;
a=c;
b=d;
goto start;
case 'R':
case 'r':
goto begin;
case 'J':
case 'j':
f=curcolor+1;
putpixel(a,b,f);
gotoxy(1,2);
printf("X=%d,Y=%d",a,b);
sound(100);
getch();
gotoxy(1,2);
printf(" ");
nosound();
goto start;
case 'C':
case 'c':
drcir(a,b,curcolor);
goto start;
case 'A':
case 'a':
drarc(a,b,curcolor);
goto start;
case 'T':
case 't':
gotoxy(1,2);
printf("Enter color code:");
e=getche();
curcolor=e;
setcolor(curcolor);
gotoxy(1,2);
printf(" ");
goto start;
case 'B':
case 'b':
cleardevice();
goto verybegin;
default:
goto start;
}
end:
cleardevice();
closegraph();
}
void drcir(int x,int y,int ccolor)
{
int r;
gotoxy(1,2);
printf("Enter Radius of Circle:");
scanf("%d",&r);
gotoxy(1,2);
printf(" ");
setcolor(ccolor);
circle(x,y,r);
}
void drarc(int x,int y,int ccolor)
{
int r,sa,ea;
gotoxy(1,2);
printf("Enter Radius:");
scanf("%d",&r);
gotoxy(1,2);
printf(" ");
gotoxy(1,2);
printf("Enter Starting Angle:");
scanf("%d",&sa);
gotoxy(1,2);
printf(" ");
gotoxy(1,2);
printf("Enter Ending Angle:");
scanf("%d",&ea);
gotoxy(1,2);
printf(" ");
setcolor(ccolor);
arc(x,y,sa,ea,r);
}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG