My Blog List

Tuesday, 28 July 2015

Computer Graphics

Computer Graphics

Computer graphics is extensive, complex and diversified technology. Computer Graphics is a field of computer science that is concerned with digitally synthesizing and manipulating visual contents. It a technique of manipulate visual and geometric information using computational techniques. Computer graphics refers to the creation, storage and manipulation of pictures and drawings using a digital computer. Computer graphics are pictures that are generated by a computer using different technique. With developments in computing technology interactive computer graphics has become an effective tool for presentation of information in such diverse fields as science, engineering, medicine, business, industry, government, art, entertainment, advertising, education, and training. There is virtually no field in which graphical displays cannot be used to some advantage and that is the basic reason why application of computer graphics is so widespread.
Graphical representation makes the study of anything much more interesting. It is a fact that one picture is worth a thousand words. So quite naturally interfaces empowered with Graphics enhances the communication between the computer and its users. Representation of a huge numbers in the form of a graph or a picture helps in better understanding and interpretation of the characteristics or pattern of the data contained in the set of numbers. Graphic displays also improve understanding complex systems, and visualization of two-dimensional (2D), three-dimensional (3D) objects.
Two major 2D graphic types: Bitmap (Raster) and Vector images.

Raster Graphics

Raster Graphics consist of illustrations created using pixels; Rectangular grid of cells of equal size and each cell has its own color. These cells are also called pixels. Raster graphics are also called bitmaps. Digital photographs are the most common type of raster graphics.
Digital photographs in general are raster graphics. Digital camera, uses a certain number of megapixels. This refers to the number of pixels used for a single picture. A defining characteristic of a raster graphic is that when it’s zoomed in very closely, it start to show the actual pixels.
An important property of a raster graphic is its resolution. Resolution indicates the amount of detail, so a higher resolution means more detail. Higher resolution means more pixels, which is why a larger number of megapixels for a digital camera results in sharper photographs.

Vector graphics

Vector graphics consist of illustrations created using line work. In technical terms, you use points, lines, curves and shapes to create the illustration. Vector graphics are based on vectors, also referred to as paths. One of the key characteristics of a vector graphic is that the line work is sharp, even when zoomed in very closely. In a computer application, the line work is stored as a mathematical formula that describes the exact shape of the line. So when its zoomed in, remains a line.

Photo-realistic illustration that is not actually a photograph, the illustration typically consists of very detailed vector graphic containing hundreds or thousands of lines. Vector graphics are created and edited using illustration software. There are a number of different illustration applications. One of the most widely used ones is Illustrator by Adobe. Others include CorelDraw by the Corel Corporation and the open source applications Inkscape and Xara Xtreme. Vector graphics can be stored in a number of different file formats, including AI, EMF, SVG and MWF.

COBOL & Four Divisions

COBOL

COBOL is a language that was developed specifically for business programming. It actually can be used for a wide range of programs and programming problems, but it is most popular for handling traditional business activities. COBOL excels in accounting systems and related activities such as inventory control, retail sales tracking, contact management, commissions, payroll--the list is almost endless.
It is the most widespread commercial programming language in use today. It is English-like and easy to read. This makes it very popular with nonprogrammers. Financial officers frequently can read a section of a COBOL program and understand what it is doing with figures, without having to rely on programmers to interpret the program for them.
COBOL is a high-level programming language first developed by the CODASYL Committee (Conference on Data Systems Languages) in 1960. Since then, responsibility for developing new COBOL standards has been assumed by the American National Standards Institute (ANSI).
Three ANSI standards for COBOL have been produced: in 1968, 1974 and 1985. A new COBOL standard introducing object-oriented programming to COBOL, is due within the next few years.
The word COBOL is an acronym that stands for COmmon Business Oriented Language. As the expanded acronym indicates, COBOL is designed for developing business, typically file-oriented, applications. It is not designed for writing systems programs. For instance you would not develop an operating system or a compiler using COBOL.

The Four Divisions

At the top of the COBOL hierarchy are the four divisions. These divide the program into distinct structural elements. Although some of the divisions may be omitted, the sequence in which they are specified is fixed, and must follow the order below.
IDENTIFICATION DIVISION.
Contains program information
ENVIRONMENT DIVISION.
Contains environment information
DATA DIVISION.
Contains data descriptions
PROCEDURE DIVISION.
Contains the program algorithms

The IDENTIFICATION DIVISION

The IDENTIFICATION DIVISION supplies information about the program to the programmer and the compiler.
Most entries in the IDENTIFICATION DIVISION are directed at the programmer. The compiler treats them as comments.
The PROGRAM-ID clause is an exception to this rule. Every COBOL program must have a PROGRAM-ID because the name specified after this clause is used by the linker when linking a number of subprograms into one run unit, and by the CALL statement when transferring control to a subprogram.
The IDENTIFICATION DIVISION has the following structure:
IDENTIFICATION DIVISION
PROGRAM-ID. NameOfProgram.
[AUTHOR. YourName.]
other entries here

The keywords - IDENTIFICATION DIVISION - represent the division header, and signal the commencement of the program text.
PROGRAM-ID is a paragraph name that must be specified immediately after the division header.
NameOfProgram is a name devised by the programmer, and must satisfy the rules for user-defined names.
Here's a typical program fragment:
IDENTIFICATION DIVISION.
PROGRAM-ID. SequenceProgram.
AUTHOR. Amar Deep Gorai.

The ENVIRONMENT DIVISION

The ENVIRONMENT DIVISION is used to describe the environment in which the program will run.
The purpose of the ENVIRONMENT DIVISION is to isolate in one place all aspects of the program that are dependant upon a specific computer, device or encoding sequence.
The idea behind this is to make it easy to change the program when it has to run on a different computer or one with different peripheral devices.
In the ENVIRONMENT DIVISION, aliases are assigned to external devices, files or command sequences. Other environment details, such as the collating sequence, the currency symbol and the decimal point symbol may also be defined here.

The DATA DIVISION

As the name suggests, the DATA DIVISION provides descriptions of the data-items processed by the program.
The DATA DIVISION has two main sections: the FILE SECTION and the WORKING-STORAGE SECTION. Additional sections, such as the LINKAGE SECTION (used in subprograms) and the REPORT SECTION (used in Report Writer based programs) may also be required.
The FILE SECTION is used to describe most of the data that is sent to, or comes from, the computer's peripherals.
The WORKING-STORAGE SECTION is used to describe the general variables used in the program.

The
DATA DIVISION has the following structure and syntax:

Below is a sample program fragment -
IDENTIFICATION DIVISION.
PROGRAM-ID. SequenceProgram.
AUTHOR. Amar Deep Gorai.

DATA DIVISION.
WORKING-STORAGE SECTION.
01  Num1           PIC 9  VALUE ZEROS.
01  Num2           PIC 9  VALUE ZEROS.
01  Result         PIC 99 VALUE ZEROS.

The PROCEDURE DIVISION

The PROCEDURE DIVISION contains the code used to manipulate the data described in the DATA DIVISION. It is here that the programmer describes his algorithm.
The PROCEDURE DIVISION is hierarchical in structure and consists of sections, paragraphs, sentences and statements.
Only the section is optional. There must be at least one paragraph, sentence and statement in the PROCEDURE DIVISION.
Paragraph and section names in the PROCEDURE DIVISION are chosen by the programmer and must conform to the rules for user-defined names.

Sample Program

IDENTIFICATION DIVISION.
PROGRAM-ID. SequenceProgram.
AUTHOR. Amar Deep Gorai.                    
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num1 PIC 9 VALUE ZEROS.
01 Num2 PIC 9 VALUE ZEROS.
01 Result PIC 99 VALUE ZEROS.

PROCEDURE DIVISION.
CalculateResult.
   ACCEPT Num1.
   ACCEPT Num2.
   MULTIPLY Num1 BY Num2 GIVING Result.
   DISPLAY "Result is = ", Result.
   STOP RUN.
                  

Some COBOL compilers require that all the divisions be present in a program while others only require the IDENTIFICATION DIVISION and the PROCEDURE DIVISION. For instance the program shown below is perfectly valid when compiled with the Microfocus NetExpress compiler.

Minimum COBOL program

IDENTIFICATION DIVISION.
PROGRAM-ID.  SmallestProgram.
PROCEDURE DIVISION.
DisplayGreeting.
   DISPLAY "Hello world".
   STOP RUN.