CHAPTER 6 Graphics
What is meant by computer graphics? What do you know about different modes of graphics in BASIC? Explain.
Computer graphics: – Graphics is that area of computer programming which is highly in use these days. It is that type of programming in which we draw text or pictures i.e., shape and images on the screen of the computer.
Types of Graphics: – There are three modes of drawing Graphics.
- Text Mode: – It is the first mode of drawing graphics and it refers to drawing number, letter and special characters (like $, % and so on) in the graphics form like high lighting, make them blinking or to convert them into invisible form.
In text mode these characters are displayed in terms of 25 rows x 40 columns or 25 rows x 80 columns on the screen of the computer monitor.
- Medium-Resolution Graphics Mode:- In this mode of Graphics, the display is divide into a matrix consisting of 320 columns and 200 rows of pixels. This graphical mode works with 4 columns. The columns are numbered from 0 to 319 and the rows from 0 to 199.
- High-resolution graphics Mode: – High-Resolution graphics Mode contains more pixels than the medium resolution mode. In this mode the screen is divided into 640 columns and 200 rows which make a matrix of 640 x 200 pixels. This high resolution is used to facilitate more precise and clear drawing of graphics.
Why do we use CIRCLE statement? Explain with suitable example.
Some time we need to make a circle. In order to draw a circle, we use the CIRCLE statements. This statement has the following general form:
Line# CIRCLE(X, Y), radius [colour].
Where (x,y) is the position of the point that is located at the center of the circle and radius is the radius of the circle. The colour value is optional and is used to colour the circle with specific colour selected according to the graphic mode and the available colour palette. An example may be:
20 CIRCLES (110,150), 70
Which is used to draw a circle of radius equal to 10 and having the pixel located at?
(110,150) as its center.
Example: – This program is used to draw a circle one with in another by using CRICLE statements, as following:
20 SCREEN 1
30 FOR = 60 TO 10 STEP 10
40 CRICLE (100,50);I
50 NEXT I
Write the purpose and complete syntax of DRAW statements. What types of shapes you can draw with this statement? Give two examples.
This statement is used to draw lines and other shapes on the screen of the monitor. This statement is used in both the resolution graphics modes, which are the medium resolution and high resolution graphics mode.
The general form of DRAW statements is:
Line # DRAW string
Where string may be enclosed in quotes and it’s contain commands to create a shape on the screen. This string may be using one of the following commands:
“Un” is used to move up n points or pixels.
“Dn” for moving down by n points or pixels.
“Fn” for moving left n points or pixels.
“R” for moving right n points or pixels.
“En” for moving diagonally down and right by n points i.e., pixels.
“Gn” for moving diagonally down and left by n points i.e., pixels.
“Hn” for moving diagonally up and left by n points or pixels.
When one of these commands is executed, a line is drawing n from the starting position which has been specified. Thus this drawing utility of BASIC language is used to specify the number of points or pixels and the specific direction in which the line is to be drawn.
By DRAW statements we draw the following shapes:-
This program is used to draw a square.
20 SCREEN 1
Program 2:- This program is written to draw a rectangle.
20 SCREEN 1
30 DRAW “U40R70D40L70”
What is the role of SCREEN statements? Write down its different modes and their effect on the graphic quality.
SCREEN statement:- SCREEN statement insert effect on the graphic quality.
It must be notified that the statement SCRREN 1 is used to select an appropriate screen mode i.e., Medium Resolution graphics mode. The general form of the SCREEN statement is:
Line # SCREEN Mode.
There are three modes of SCREEN statement:-
- Mode = 0:- If mode = 0 that is, SCREEN 0, then text is selected.
- Mode = 1:- If mode = 1 that is, SCREEN 1, then Medium Resolution mode of graphic will be set.
- Mode = 2:- If mode = 2 that is, SCREEN 2, then High Resolution mode of graphic will be set.