Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



A Simple 2D-Drawing Program


Posted Date: 12 Jun 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: Lenin       Member Level: Diamond
Rating:     Points: 1



A Simple 2D-Drawing Program

#include
#include
#include
#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


");
printf(" N(Up Arrow) = North
");
printf(" S(Down Arrow) = South
");
printf(" E(Right Arrow) = East
");
printf(" W(Left Arrow) = West
");
printf(" F(Page Up) = North-East
");
printf(" X(Home) = North-West
");
printf(" D(Page Down) = South-East
");
printf(" Z(End) = South-West
");
printf(" J = Current Position
");
printf(" B = Help(This Screen)
");
printf(" R(Insert) = Reset
");
printf(" T = Color Change(0-9)
");
printf(" C = Circle
");
printf(" A = Arc
");
printf(" ESC = Quit
");
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);
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Transformation 2D [ Scaling, Translation, Rotation . . .]
Previous Resource: Shsort, shell sort [array]
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.