Professional Documents
Culture Documents
Reg.No:-11111427
Term Paper On Design an Add of any company using Graphics Submitted By: Adesh Mishra Reg.No.1111427 Roll No: A21 Section: D1R02 Submitted To: Mansi Rana
Adesh Mishra
Reg.No:-11111427
Acknowledgement
This project is done as a semester miniproject, as a part of course titled Computer Graphics. We are really thankful to our course instructor Mansi Rana, for his invaluable guidance and assistance, without which the accomplishment of the task would have never been possible. In our present project we have chosen the topic- Design an Add of any
Adesh Mishra
Reg.No:-11111427
TABLE OF CONTENTS
1.
2. Working of project 3. Graphics in C Language Graphics mode initialization Graphics Driver & mode 4. Graphics function used in project 5. System Requirement Software Requirement Hardware Requirement 6. Coding 7. Snapshots 8. Conclusion 9. Bibliography
Adesh Mishra
Reg.No:-11111427
Adesh Mishra
Reg.No:-11111427
2. Working of Project
Computer Graphics has many different applications, and gaming is probably one of the most obvious. We can design any animation & advertisement of the Company. I choose to design an interactive advertisement of the Vodafone Company in which we design the mucky mouse image and Vodafone Logo. In this project we design add of Vodafone Company is the most realistic and most impressive. This project can be run on any operating system in which Turbo c should be installed.
3. Graphics in C Language
We will restrict our discussion on Graphics in C Language to 16 bit C programming and MS DOS environment. In a C Program first of all you need to initialize the graphics drivers on the computer. This is done using the initgraph method provided in graphics.h library. In the next few pages we will discuss graphics.h library in details. Important functions in graphic.h library will be discuses in details and samples programmed will be provided to show the power of C programming language. Graphics mode Initialization First of all we have to call the initgraph function that will intialize the graphics mode on the computer. initigraph have the following prototype. Void initgraph (int far graphdriver, int far graphmode, char far pathtodriver); Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode.Initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their defaults, then resets graphresult to 0. graphdriver Integer that specifies the graphics driver to be used. You can give graphdriver a value using a constant of the graphics_drivers enumeration type. graphmode
Adesh Mishra
Reg.No:-11111427
Integer that specifies the initial graphics mode (unless graphdriver = DETECT). If graphdriver = DETECT, initgraph sets graphmode to the highest resolution available for the detected driver. We can give graphmode a value using a constant of the graphics_modes enumeration type. pathtodriver Specifies the directory path where initgraph looks for graphics drivers (.BGI) first. 1. If theyre not there, initgraph looks in the current directory. 2. If pathtodriver is null, the driver files must be in the current directory. graphdriver and graphmode must be set to valid graphics_drivers and graphics_mode values or youll get unpredictable results. (The exception is graphdriver = DETECT.) After a call to initgraph, graphdriver is set to the current graphics driver, and graphmode is set to the current graphics mode. You can tell initgraph to use a particular graphics driver and mode, or to autodetect the attached video adapter at run time and pick the corresponding driver. If you tell initgraph to autodetect, it calls detectgraph to select a graphics driver and mode. Normally, initgraph loads a graphics driver by allocating memory for the driver (through _graphgetmem), then loading the appropriate .BGI file from disk.As an alternative to this dynamic loading scheme, you can link a graphics driver file (or several of them) directly into your executable program file I have used some header files like as #include<conio.h> It is used for console input output. #include<stdio.h> It is used for stander input output. #include<dos.h> I have used this header file for delay function.
Adesh Mishra
Reg.No:-11111427
#include<stdlib.h> I have used this header file for random function. #include<graphics.h>
C graphics using graphics.h functions can be used to draw different shapes, display text in different fonts, change color and many more. Using functions of graphics.h in turbo c compiler you can make graphics programs, animations, projects and games. You can draw circles, lines, rectangles, bars and many other geometrical figures. You can change their colors using the available functions and fill them. 4. GRAPHICS FUNCTIONS USED IN THE PROJECT: circle() : Draws a circle with the specified center and radius. SYNTAX: void circle(int x, int y, int radius); PARAMETERS: (x, y)-------centre of the circle radius ----radius of the circle. Closegraph(): Deallocates all the memory allocated by the graphics system. SYNTAX: void closegraph (void); floodfill(): Flood-fills the bounded region. SYNTAX: floodfill(int x,int y,int border);
Adesh Mishra
Reg.No:-11111427
(x,y) is a seed point within the enclosed area to be filled. The area bounded by the color border is flooded with the current fill pattern and fill color Cleardevice: Clears the graphics screen and moves the current position to (0,0). SYNTAX: void cleardevice(); Cleardevice: Clears the graphics screen and moves the current position to (0,0). SYNTAX: void cleardevice(); Getcolor: Returns the current drawing color. SYNTAX: int getcolor(); The drawing color is the value to which pixels are set when lines, rectangles etc are drawn. Initgraph: Initializes the graphics system SYNTAX: void far initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver); Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver) then putting the system into graphics mode. Outtextxy: Outtextxy displays a string at the specified location (graphics mode) SYNTAX: void far outtextxy(int x, int y, char far textstring);
Adesh Mishra
Reg.No:-11111427
outtextxy display a text string, using the current justification settings and the current font, direction, and size. outtextxy displays textstring in the viewport at the position (x, y)
setfillstyle: Sets the fill pattern and color SYNTAX: void setfillstyle(int pattern, int color); setfillstyle sets the current fill pattern and fill color. Sets the current line style and width or pattern
5. SYSTEM REQUIRMENTS
Software Requirement Operating system: MS Windows XP or Windows Vista Language: Application c/c++ turcoc3, Tc, devc compiler
Hardware Requirement Processor: RAM: Hard disk: Pentium IV Processor 512 MB 80 GB(min)
Adesh Mishra
Reg.No:-11111427
6. Source Code
#include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gdriver = DETECT, gmode, errorcode,i; initgraph(&gdriver, &gmode, "..//bgi"); //setfillstyle(5,BLUE); //floodfill(24,4,WHITE); settextstyle(1,0,4); for(i=1;i<14;i++) { setbkcolor(i); //outtextxy(500,200,"MICKY MOUSE"); arc(240,40,-407,235,30); arc(245,120,-430,190,60); arc(333,110,-511,170,30); ellipse(155,130,0,360,17,25);
Adesh Mishra
Reg.No:-11111427
ellipse(194,150,170,360,55,30); ellipse(162,175,30,80,55,50); arc(253,180,80,110,30); ellipse(198,130,-31,180,9,20); ellipse(232,120,0,360,9,20); arc(235,177,240,370,30); line(222,204,190,180); arc(232,171,210,385,23); arc(250,275,120,190,110); arc(400,310,140,220,160); arc(186,270,0,120,60); line(141,293,125,330); ellipse(216,355,-2,273,30,8); ellipse(154,333,25,270,30,5); line(185,353,181,300); line(153,330,162,390); line(190,360,195,390); line(213,347,230,410); arc(178,380,200,340,18); arc(253,400,200,335,25); ellipse(179,390,150,403,23,17); ellipse(255,415,150,408,28,17);
Adesh Mishra
Reg.No:-11111427
ellipse(255,440,110,435,75,35); ellipse(160,417,90,287,75,35); line(203,393,216,409); line(170,200,105,230); ellipse(120,248,40,180,35,20); ellipse(120,295,68,230,60,55); ellipse(100,332,170,290,20,10); ellipse(120,333,170,318,20,10); ellipse(300,225,-5,110,95,45); ellipse(302,250,0,110,70,45); line(395,220,398,250); ellipse(385,262,-10,180,20,15); ellipse(373,300,-50,220,55,40); ellipse(393,330,250,40,15,5); ellipse(375,330,230,40,15,5); arc(350,317,190,350,20); ellipse(165,260,0,360,8,15); ellipse(200,265,0,360,8,15); ellipse(195,128,0,360,4,7); setfillstyle(5,RED); //floodfill(227,125,WHITE); ellipse(227,125,0,360,4,12);
Adesh Mishra
Reg.No:-11111427
outtextxy(390,40,"HuTch"); setcolor(BLUE); outtextxy(410,100," Is NoW "); setcolor(RED); outtextxy(440,160,"Vodafone"); setcolor(WHITE); circle(560,300,60); setfillstyle(1,7); floodfill(510,300,15); setcolor(RED); circle(566,299,32); ellipse(570,283,85,238,36,41); arc(582,266,100,210,24); setfillstyle(1,RED); floodfill(565,308,RED); floodfill(550,265,RED); setcolor(15); delay(700); } getch(); closegraph(); }
Adesh Mishra
Reg.No:-11111427
7. SCREEN SHOTS
Adesh Mishra
Reg.No:-11111427
Adesh Mishra
Reg.No:-11111427
8. Conclusion
The aim of the project was exhaustive and exploratory study of Computer Graphics under C. The programming uses the basic graphics functions and techniques. Though not as sophisticated as the same, it nevertheless provides all the basic requirements expected out of a graphics. It can be further improved upon to provide better facilities and user interface.
Adesh Mishra
Reg.No:-11111427
9.BIBLIOGRAPHY
[1] Yashwant Kanitkar, Graphics under C, Third edition, 2003 [2] Foley, Van Dam, Computer Graphics Principles and Practice, Seventh edition, 2004. [3] Hearn, Baker, Computer Graphics C version, Second edition, 2005. [4] William Newman, Robert Sproull, Principles of interactive Computer Graphics, Second edition.