Add to Favorites    Make Home Page 14331 Online  
 Language Categories  
 Our Services  

Home » C Home » Games and Graphics Home » A Simple 2D-Drawing Program

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title A Simple 2D-Drawing Program
Author Harshvir Singh Sidhu
Author Email hvssidhu [at] yahoo.com
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.
Category C » Games and Graphics
Hits 381526
Code Select and Copy the Code
#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 "); 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); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=627


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review