0% found this document useful (0 votes)
23 views

Group c Assignment 7 Man Walking in Rain

Uploaded by

sayleebandal312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Group c Assignment 7 Man Walking in Rain

Uploaded by

sayleebandal312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment No: 7

PROBLEM STATEMENT:
Write C++ program to to draw man walking in the rain with an umbrella. Apply the
concept of polymorphism.

PREREQUISITES:
Basic knowledge of graphics primitives.

COURSE OBJECTIVE:
1. To implement the features of graphics.
2. To interface the applications of graphics to the real world.
3. To give some benefits to the disability.
4. To make the life easier.
5. To become familiarization with Graphics and its logical coding.

COURSE OUTCOME:
To understand the concepts related to polymorphism and graphics primitives.

THEORY:
Computer Graphics has revolutionized almost every computer-based application in
science and technology. Information technology is a trend today.The importance of
computer graphics lies in its applications. In engineering applications (e.g. automotive
and aerospace) the ability to quickly visualize newly designed shapes is indispensible.
Computer graphics has also expanded the boundaries of art and entertainment. Movies
such as “JURASSIC PARK” make extensive use of computer graphics to create images
that test the bounds of imagination. The development of computer graphics has made
possible virtual reality, a synthetic reality that exists only inside a computer. Virtual
reality is fast becoming an indispensable tool in education. Flight simulators are used to
train pilot for extreme conditions. Surgical simulators are used to train novice surgeons
without endangering patients.

Figure: Sample graphics program


This program initializes graphics mode and then closes it after a key is pressed. To
begin with we have declared two variables of int type gd and gm for graphics driver and
graphics mode respectively, you can choose any other variable name as you wish.
DETECT is a macro defined in "graphics.h" header file, then we have passed three
arguments to initgraph function first is the address of gd, second is the address of gm and
third is the path where your BGI files are present (we have adjusted this accordingly
where our turbo compiler is installed). Initgraph function automatically decides an
appropriate graphics driver and mode such that maximum screen resolution is set, getch ()
helps us to wait until a key is pressed, closegraph () function closes the graphics mode
and finally return statement returns a value 0 to main indicating successful execution of
your program.
Some of the function included in<graphics.h> used in our program:

Line function:line function is used to draw a line from a point(x1,y1) to point(x2,y2)


i.e.(x1,y1) and(x2,y2) are end points of the line. The code given below draws a line.
Declaration: - void line (int x1, int y1, int x2, int y2);

Circle function: Circle function is used to draw a circle with center (x, y) and third
parameter specifies the radius of the circle. The code given below draws a circle.
Declaration: - void circle (int x, int y, int radius);

Setcolor function: In Turbo Graphics each color is assigned a number. Total 16 colors
are available. Strictly speaking number of available colors depends on current graphics
mode and driver. For Example :- BLACK is assigned 0, RED is assigned 4 etc. setcolor
function is used to change the current drawing color.e.g. Setcolor (RED) or setcolor(4)
changes the current drawing color to RED. Remember that default drawing color is
WHITE.
Declaration: - void setcolor (int color);

Outtextxy function:Outtextxy function display text or string at a specified point(x, y)


on the screen.
Declaration: - void Outtextxy (int x, int y, char *string);
x, y are coordinates of the point and third argument contains the address of
string to be displayed.

Getmaxx function: getmaxx function returns the maximum X coordinate for current
graphics mode and driver.
Declaration:-int getmaxx ();
Getmaxy function: getmaxy function returns the maximum Y coordinate for current
graphics mode and driver.
Declaration:- intgetmaxy();

Setlinestyle function: Setlinestyle function sets line style, thickness, unsigned upattern
etc.
Declaration: - void setlinestyle (intlinestyle, unsigned upattern, int thickness);
Putpixel function: putpixel function plots a pixel at location (x, y) of specified color.
Declaration: - void putpixel (int x, int y, int color);
For example if we want to draw a GREEN color pixel at (35, 45) then we will
write putpixel (35, 35, GREEN); in our c program, putpixel function can be used
to draw circles, lines and ellipses using various algorithms.

Setfillstyle function: setfillstyle function sets the current fill pattern and fill color.
Declaration: - void setfillstyle (int pattern, int color);

Figure: Walking man in the rain with an umbrella

CONCLUSION: Using the concept of transformation, an illusion of moving object is


achieved.

You might also like