You are on page 1of 29

Introduction to Computer Graphics

Computer Graphics involves technology to access. The Process transforms and presents
information in a visual form. The role of computer graphics insensible.

In today life, computer graphics has now become a common element in user interfaces, T.V.
commercial motion pictures.

Computer Graphics is the creation of pictures with the help of a computer. The end product of
the computer graphics is a picture it may be a business graph, drawing, and engineering.

In computer graphics, two or three-dimensional pictures can be created that are used for research.
Many hardware devices algorithm has been developing for improving the speed of picture
generation with the passes of time. It includes the creation storage of models and image of
objects. These models for various fields like engineering, mathematical and so on.

Today computer graphics is entirely different from the earlier one. It is not possible. It is an
interactive user can control the structure of an object of various input devices.

Definition of Computer Graphics:

“It is the use of computers to create and manipulate pictures on a display device. It comprises
of software techniques to create, store, modify, represents pictures”.

1
Types of Computer Graphics

Computer Graphics can be broadly divided into two categories:

Non Interactive Computer Graphics: In non-interactive computer graphics


otherwise known as passive computer graphics, the observer has no control over
the image. Familiar examples of this type of computer graphics include the titles
shown on TV and other forms of computer art. Interactive Computer Graphics:
Interactive Computer Graphics involves a two way communication between
computer and user. Here the observer is given some control over the image by
providing him with an input device for example the video game controller of the
ping pong game. This helps him to signal his request to the computer. The
computer on receiving signals from the input device can modify the displayed
picture appropriately. To the user it appears that the picture is changing
instantaneously in response to his commands. He can give a series of commands,
each one generating a graphical response from the computer. In this way he
maintains a conversation, or dialogue, with the computer.

Interactive computer graphics: It affects our lives in a number of indirect ways.


For example, it helps to train the pilots of our airplanes. We can create a flight
simulator which may help the pilots to get trained not in a real aircraft but on the
grounds at the control of the flight simulator. The flight simulator is a mockup of
an aircraft flight deck, containing all the usual controls and surrounded by screens
on which we have the projected computer generated views of the terrain visible on
take-off and landing. Flight simulators have many advantages over the real
aircrafts for training purposes, including fuel savings, safety, and the ability to
familiarize the trainee with a large number of the world‟s airports.

2
Applications of Computer Graphics

1. Education and Training: Computer-generated model of the physical, financial


and economic system is often used as educational aids. Model of physical systems,
physiological system, population trends or equipment can help trainees to
understand the operation of the system. For some training applications, particular
systems are designed. For example: Flight Simulator.

Flight Simulator: It helps in giving training to the pilots of airplanes. These pilots
spend much of their training not in a real aircraft but on the ground at the controls
of a Flight Simulator.

Advantages:

o Fuel Saving

o Safety

o Ability to familiarize the training with a large number of the world's airports.

2. Use in Biology: Molecular biologist can display a picture of molecules and gain
insight into their structure with the help of computer graphics.

3. Computer-Generated Maps: Town planners and transportation engineers can


use computer-generated maps which display data useful to them in their planning
work.

4. Architect: Architect can explore an alternative solution to design problems at an


interactive graphics terminal. In this way, they can test many more solutions that
would not be possible without the computer.

3
5. Presentation Graphics: Example of presentation Graphics are bar charts, line
graphs, pie charts and other displays showing relationships between multiple
parameters. Presentation Graphics is commonly used to summarize

o Financial Reports

o Statistical Reports

o Mathematical Reports

o Scientific Reports

o Economic Data for research reports

o Managerial Reports

o Consumer Information Bulletins

o And other types of reports

6. Computer Art: Computer Graphics are also used in the field of commercial
arts. It is used to generate television and advertising commercial.

7. Entertainment: Computer Graphics are now commonly used in making motion


pictures, music videos and television shows.

8. Visualization: It is used for visualization of scientists, engineers, medical


personnel, business analysts for the study of a large amount of information.

9. Educational Software: Computer Graphics is used in the development of


educational software for making computer-aided instruction.

4
Graphical Functions

Computer Graphics have predefined functions. These functions contains header


file graphics.h. This header file is used to include and facilitate graphical
operations in program graphics.h functions can be used to draw different shapes,
display text in different fonts, change colors and many more. Using functions of
graphics.h 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. Those functions
are as follows:

1. Outtext()

Purpose: outtext() function is used to display the text on the screen, using this
function text is display in the current position.

Syntax:outtext(STRING);

Example:outtex(“HELLO”);

2. Putpixel()

Purpose:-Putpixel function is to draw the pixel on the screen. Pixel is small dot
on the screen.

Syntax:-putpixel(x co-orinate, y co-ordinate,COLOR);

Example: – putpixel(100,100,BLUE);

3. SetbkColor()

Purpose:-Setbkcolor function is used to set background color of the screen.

Syntax:-setbkcolor(COLOR);

5
Example:-setbkcolor(RED);

4. Setlinestyle()

Purpose:-setlinestyle function is used to set the current line style, width and
pattern

Syntax:-setlinestyle(linestyle, pattern, thickness);

Example:-setlinestyle(SOLID_LINE,1,2);

5. Setcolor()

Purpose:-setcolor is to set color of the objects which is to be drawn after this


setcolor line.

Syntax:-setcolor(COLOR);

Example:-setcolor(RED);

6. Rectange()

Purpose:- Rectangle function is used to draw the rectangle on the screen. X1,y1
are the lower left co-ordinates of the rectangle and the x2,y2 are the upper right co-
ordinates of the rectangle.

Syntax:– rectangle(x1,,y1,x2,y2);

Example:– rectangle(100,100,200,200);

7 Getx()

Purpose:-getx returns the current position‟s of x o-ordinate

Syntax:-getx();

Example:-x=getx();

6
8 Gety()

Purpose:-gety returns the current position‟s of y co-ordinate

Syntax:-gety();

Example:-y=gety();

9 Getmaxx()

Purpose:-getmaxxreturns the maximum x co-ordinate on the screen

Syntax:-getmaxx();

Example:-maxx=getmaxx();

10 Getmaxy()

Purpose:-getmaxy returns the maximum y co-ordinate on the screen

Syntax:-getmaxy();

Example:-maxy=getmaxy();

11 Line()

Purpose:-Line function is used to draw the line on the screen.

Syntax: line(x1,y1,x2,y2);

Example:-line(100,100,200,100);

12 Closegraph()

Purpose:-closegraph function shut down the graphic system

Syntax:-closegraph();

Example:-closegraph();

7
13 Moveto()

Purpose:-moveto function moves current cursor position on the screen

Syntax:-moveto(x co-ordinate, y co-ordinate);

Example:-moveto(getmaxx/2, getmaxy/2);

14 Settextstyle()

Purpose:-settextstyle sets the current text characteristics like font, direction and
size

Syntax:-settextstyle(font, direction size);

Example:-settextstyle(1,1,10);

15 Circle()

Purpose: Circle function is used to draw the circle on the screen

Syntax:– circle(x,y,radius);

Example:circle(100,100,50);

16 Cleardevice()

Purpose: cleardevice function is used to clear the contents or graphic images on


the screen in graphics mode.

Syntax:cleardevice();

Example:cleardevice();

17 Outtextxy()

Purpose: outtextxy function is used to print the text on the screen in graphics
mode.

Syntax:outtext(x,y,text);

8
Example:-outtextxy(100,100,”HELLO”);

18 Arc()

Purpose:arc draws the arc on the screen, arc is a part of the circle

Syntax:arc(x, y, starting angle, ending angle, radius);

Example:arc( 100,100,90,180,50);

19 Setfillstyle()

Purpose: setfillstyle is used to set the color and style to be filled in the object
using the flood fill method.

Syntax:stefillstyle(STYLE, COLOR);

Example:setfillstyle(1,RED);

20 Floodfill()

Purpose:floodfill function is used to fill the color in the object, object may be
circle, rectangle or any other closed image.

Syntax:floodfill(x,y,boundary color);

Example:floodfill(100,100,BLUE);

21 Ellipse()

Purpose:ellipse function is used to draw the ellipse on the screen.

Syntax:ellipse(x, y, starting angle, ending angle, xradius, yradius);

Example:ellipse(100,100,90,200,20,20);

22 Outtext()

Purpose:outtext function is used to display the text on the screen, using this
function text is display in the current position.

9
Syntax:outtext(STRING);

Example:outtex(“HELLO”);

23 Getcolor()

Purpose:getcolor returns the current drawing color.

Syntax:getcolor();

Example:intclr = getcolor();

24 Getpixel()

Purpose:getpixel gets the color of a specified pixel.

Syntax:getpixel(x,y);

Example: color=getpixel(100,100);

10
SRS Report

Software Requirement Specification (SRS):

A software requirements specification (SRS) is a detailed description of a software


system to be developed with its functional and non-functional requirements. The
SRS is developed based the agreement between customer and contractors. It may
include the use cases of how user is going to interact with software system. The
software requirement specification document consistent of all necessary
requirements required for project development. To develop the software system we
should have clear understanding of Software system. To achieve this we need to
continuous communication with customers to gather all requirements.

A good SRS defines the how Software System will interact with all internal
modules, hardware, communication with other programs and human user
interactions with wide range of real life scenarios. Using the Software
requirements specification (SRS) document on QA lead, managers creates test
plan. It is very important that testers must be cleared with every detail specified in
this document in order to avoid faults in test cases and its expected results.

It is highly recommended to review or test SRS documents before start writing test
cases and making any plan for testing.

Qualities of SRS:

 Correct

 Unambiguous

 Complete

 Consistent

11
 Ranked for importance and/or stability

 Verifiable

 Modifiable

 Traceable

Types of Requirements:

The below diagram depicts the various types of requirements that are captured
during SRS.

Let‟s see how to test SRS and the important point to keep in mind while testing it.

1. Correctness of SRS should be checked. Since the whole testing phase is


dependent on SRS, it is very important to check its correctness. There are some
standards with which we can compare and verify.

12
2. Ambiguity should be avoided. Sometimes in SRS, some words have more than
one meaning and this might confused testers making it difficult to get the exact
reference. It is advisable to check for such ambiguous words and make the
meaning clear for better understanding.

3. Requirements should be complete. When tester writes test cases, what exactly
is required from the application, is the first thing which needs to be clear. For e.g.
if application needs to send the specific data of some specific size then it should be
clearly mentioned in SRS that how much data and what is the size limit to send.

4. Consistent requirements The SRS should be consistent within itself and


consistent to its reference documents. If you call an input “Start and Stop” in one
place, don‟t call it “Start/Stop” in another. This sets the standard and should be
followed throughout the testing phase.

5. Verification of expected result: SRS should not have statements like “Work as
expected”, it should be clearly stated that what is expected since different testers
would have different thinking aspects and may draw different results from this
statement.

6. Testing environment: some applications need specific conditions to test and


also a particular environment for accurate result. SRS should have clear
documentation on what type of environment is needed to set up.

7. Pre-conditions defined clearly: one of the most important part of test cases is
pre-conditions. If they are not met properly then actual result will always be
different expected result. Verify that in SRS, all the pre-conditions are mentioned
clearly.

8. Requirements ID: these are the base of test case template. Based on
requirement Ids, test case ids are written. Also, requirements ids make it easy to

13
categorize modules so just by looking at them, tester will know which module to
refer. SRS must have them such as id defines a particular module.

9. Security and Performance criteria: security is priority when a software is


tested especially when it is built in such a way that it contains some crucial
information when leaked can cause harm to business. Tester should check that all
the security related requirements are properly defined and are clear to him. Also,
when we talk about performance of a software, it plays a very important role in
business so all the requirements related to performance must be clear to the tester
and he must also know when and how much stress or load testing should be done
to test the performance.

10. Assumption should be avoided: sometimes when requirement is not cleared


to tester, he tends to make some assumptions related to it, which is not a right way
to do testing as assumptions could go wrong and hence, test results may vary. It is
better to avoid assumptions and ask clients about all the “missing requirements” to
have a better understanding of expected results.

11. Deletion of irrelevant requirements: there are more than one team who work
on SRS so it might be possible that some irrelevant requirements are included in
SRS. Based on the understanding of the software, tester can find out which are
these requirements and remove them to avoid confusions and reduce work load.

12. Freeze requirements: when an ambiguous or incomplete requirement is sent


to client to analyze and tester gets a reply, that requirement result will be updated
in the next SRS version and client will freeze that requirement. Freezing here
means that result will not change again until and unless some major addition or
modification is introduced in the software.

14
1. Introduction about Bubble Sort:
Bubble Sort is a sorting algorithm, which is commonly used in computer
science. Bubble Sort is based on the idea of repeatedly comparing pairs of adjacent
elements and then swapping their positions if they exist in the wrong order.

Bubble Sort Algorithm: Steps on how it works:

1. In an unsorted array of 5 elements, start with the first two elements and sort them in
ascending order. (Compare the element to check which one is greater).

2. Compare the second and third element to check which one is greater, and sort them
in ascending order. Compare the third and fourth element to check which one is
greater, and sort them in ascending order.

3. Compare the fourth and fifth element to check which one is greater, and sort them
in ascending order.

4. Repeat steps 1–5 until no more swaps are required.

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that
repeatedly steps through the list, compares adjacent elements and swaps them if
they are in the wrong order. The pass through the list is repeated until the list is
sorted. The algorithm, which is a comparison sort, is named for the way smaller or
larger elements "bubble" to the top of the list. Although the algorithm is simple, it is
too slow and impractical for most problems even when compared to insertion
sort.[2] Bubble sort can be practical if the input is in mostly sorted order with some
out-of-order elements nearly in position.

15
Below is an image of an array, which needs to be sorted.

2. System Requirements:
2.1 Hardware Requirements

 1 gigahertz (GHz) or faster 32-bit (x86) or 64-bit (x64) processor*

 1 gigabyte (GB) RAM (32-bit) or 2 GB RAM (64-bit)

 16 GB available hard disk space (32-bit) or 20 GB (64-bit)

2.2 Software Requirements

 Operating System: Windows 7

 Turbo C++ 3.7.8.9

16
3. System Design :

A good system design is to organize the program modules in such a way that are
easy to develop and change. Structured design techniques help developers to deal
with the size and complexity of programs. Analysts create instructions for the
developers about how code should be written and how pieces of code should fit
together to form a program.

Importance:

1 If any pre-existing code needs to be understood, organized and pieced together.

2 It is common for the project team to have to write some code and produce original
programs that support the application logic of the system.

There are many strategies or techniques for performing system design.

a. Bottom-up approach: The design starts with the lowest level components and
subsystems. By using these components, the next immediate higher level
components and subsystems are created or composed. The process is continued till
all the components and subsystems are composed into a single component, which
is considered as the complete system. The amount of abstraction grows high as the
design moves to more high levels. By using the basic information existing system,
when a new system needs to be created, the bottom up strategy suits the purpose.

Advantages:

1 The economics can result when general solutions can be reused.

2 It can be used to hide the low-level details of implementation and be merged with
top-down technique.

17
Disadvantages:

1 It is not so closely related to the structure of the problem.


2 High quality bottom-up solutions are very hard to construct.
3 It leads to proliferation of „potentially useful‟ functions rather than most
appropriate ones.

b. Top-down approach: Each system is divided into several subsystems and


components. Each of the subsystem is further divided into set of subsystems and
components. This process of division facilitates in forming a system hierarchy
structure. The complete software system is considered as a single entity and in
relation to the characteristics system is split into sub-system and component. The
same is done with each of the sub-system. This process is continued until the
lowest level of the system is reached. The design is started initially by defining the
system as a whole and then keeps on adding definitions of the subsystems and
components. When all the definitions are combined together, it turns out to be a
complete system. For the solutions of the software need to be developed from the
ground level, top-down design best suits the purpose.

Advantages: The main advantage of top down approach is that its strong focus on
requirements helps to make a design responsive according to its requirements.
Disadvantages:
1 Project and system boundries tends to be application specification oriented.
2 Thus it is more likely that advantages of component reuse will be missed.
3 The system is likely to miss, the benefits of a well-structured, simple
architecture.

c. Hybrid Design: It is a combination of both the top – down and bottom – up


design strategies. In this we can reuse the modules.

18
4. Source Code :
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
int el[10];
void object(int x,int y,int no);
void bubble(int n);
void flow(int f,int s);
void mixing(int f,int s);
void main()
{
int n,i,gd=DETECT,gm;
//clrscr();
initgraph(&gd,&gm,"C:\\turboc3\\bgi");
printf("enter no. of elements");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the element");
scanf("%d",&el[i]);
}
/*for(i=0;i<n;i++)
{
printf("\n%d",element[i]);

19
} */
//getch();
outtextxy(250,400,"Performing bubble sort");
for(i=0;i<n;i++)
{
setcolor(RED);
object(100+i*50,150,el[i]);
}
bubble(n);
getch();
}
void object(int x,int y,int no)
{
char s[8];
sprintf(s,"%d",no);
circle(x,y,15);
outtextxy(x-3,y-10,s);
}
void bubble(int n)
{
int i,j,temp;
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
{
if(el[j]>el[j+1])
{
flow(j,j+1);
20
temp=el[j];
el[j]=el[j+1];
el[j+1]=temp;
}
}
}
//flow
void flow(int f,int s)
{
int i;
for(i=0;i<50;i++)
{
setcolor(WHITE);
object(100+f*50,150+i*4,el[f]);
delay(15);
setcolor(0);
object(100+f*50,150+i*4,el[f]);
}
setcolor(WHITE);
object(100+f*50,150+i*4,el[f]);
//draw second object
for(i=0;i<50;i++)
{
setcolor(WHITE);
object(100+s*50,150+i*4,el[s]);
delay(10);
setcolor(0);
21
object(100+s*50,150+i*4,el[s]);
}
object(100+s*50,150+i*4,el[s]);
//mixing
mixing(f,s);
for(i=50;i>0;i--)
{
setcolor(WHITE);
object(100+f*50,150+i*4,el[s]);
delay(10);
setcolor(0);
object(100+f*50,150+i*4,el[s]);
}
setcolor(WHITE);
object(100+f*50,150+i*4,el[s]);
for(i=50;i>0;i--)
{
setcolor(WHITE);
object(100+s*50,150+i*4,el[f]);
delay(15);
setcolor(0);
object(100+s*50,150+i*4,el[f]);
}
setcolor(WHITE);
object(100+s*50,150+i*4,el[f]);
}

22
//mixing
void mixing(int f,int s)
{
int i;
for(i=0;i<(s-f)*50;i++)
{
setcolor(WHITE);
object(100+f*50+i,350,el[f]);
object(100+s*50-i,350,el[s]);
delay(20);
setcolor(0);
object(100+f*50+i,350,el[f]);
object(100+s*50-i,350,el[s]);
}
setcolor(WHITE);
object(100+f*50+i,350,el[f]);
object(100+s*50-i,350,el[s]);
}

23
5. Testing and implementation:

System testing is the stage of implementation, which is aimed at ensuring that the
system works accurately and efficiently before live operation commences. Testing
is the process of executing the program with the intent of finding errors and
missing operations and also a complete verification to determine whether the
objectives are met and the user requirements are satisfied. The ultimate aim is
quality assurance. Tests are carried out and the results are compared with the
expected document. In the case of erroneous results, debugging is done. Using
detailed testing strategies a test plan is carried out on each module.

There are different methods that can be used for software testing.

Black-Box Testing: The technique of testing without having any knowledge of the
interior workings of the application is called black-box testing. The tester is
oblivious to the system architecture and does not have access to the source code.
Typically, while performing a black-box test, a tester will interact with the system's
user interface by providing inputs and examining outputs without knowing how
and where the inputs are worked upon.

White Box Testing: White-box testing is the detailed investigation of internal


logic and structure of the code. White-box testing is also called glass testing or
open-box testing. In order to perform white-box testing on an application, a tester
needs to know the internal workings of the code. The tester needs to have a look
inside the source code and find out which unit/chunk of the code is behaving
inappropriately.

24
The various tests performed in “Network Backup System” are unit testing,
integration testing and user acceptance testing.

5.1 Unit Testing: The software units in a system are modules and routines that
are assembled and integrated to perform a specific function .Unit testing focuses
first on modules, independently of one another, to locate errors. This enables, to
detect errors in coding and logic that are contained within each module. This
testing includes entering data and ascertaining if the value matches to the type and
size supported. The various controls are tested to ensure that each performs its
action as required.

5.2 Integration Testing: Data can be lost across any interface, one module can
have an adverse effect on another, sub functions when combined, may not produce
the desired major functions. Integration testing is a systematic testing to discover
errors associated within the interface. The objective is to take unit tested modules
and build a program structure. All the modules are combined and tested as a whole.
Here the Server module and Client module options are integrated and tested. This
testing provides the assurance that the application is well integrated functional unit
with smooth transition of data. Simulation of Data structures and Algorithms
Division of Computer Engineering

5.3 User Acceptance Testing: User acceptance of a system is the key factor for
the success of any system. The system under consideration is tested for user
acceptance by constantly keeping in touch with the system users at time of
developing and making changes whenever required.

25
6. Output:

Fig. 1

Fig. 2
26
Fig. 3

Fig. 4

27
Fig. 5

Fig. 6

28
7. References:

 Computer Graphics (Second Edition)


Donald D. Hearn | M. Pauline Baker
 Interactive Computer Graphics(7th Edition)
 http://tutorialspoint.com/

29

You might also like