Resolution Refers To The Number of Lines and Columns On Computer Screen. Default Screen Has

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Computer Programing Graphics in QBasic Dr.

Usman Akmal

GRAPHICS IN QBASIC

1 LEARNING ABOUT SCREEN


Resolution refers to the number of lines and columns on computer screen. Default screen has
80 columns and 25 lines. The intersection of a row and a column represents a picture element,
or a pixel. The more rows and columns on screen result in more intersection, size of pixel will
be smaller and screen resolution will increase.

All graphics on computers are composed of many pixels. Lines, boxes and circles really are
just groups of pixels turned on while others are turned off.

The upper-left pixel is called the home location; this pixel is located at column 0, row 0 and,
therefore, has the designation (0, 0). As a rule, the column number is listed first in a pixel’s
designation. A pixel located at (34, 50), for example, is an intersection of graphics column 34
and graphics row 50.

When pixel’s location is designated with its row and column intersection, the location is known
as coordinate. The columns across the screen are known as x-coordinates, whereas the rows
down the screen are known as y-coordinates. The coordinate (9,56), therefore, refers to x-
position 9 and y-position 56.

The operating state in which one places a program by choosing among a set of operating options
is called program’s mode. To display graphics, screen must be in graphics mode. If text mode
is changed to graphics mode (using screen command), program erases text on-screen in making
the mode change.

Following is the syntax of the SCREEN command;

SCREEN mode [, colorswitch]

Mode can be any value listed in Table 1. Screen mode 0 supports only text mode.

Table 1 RGB Funtion for Standard Colors

Screen Description
Mode
0 QBasic default for text resolution of 80×25. Supports up to 16 colors (0 – 15)
320 × 200 graphics resolution. Also supports 40 × 25 text mode and 4 of 16
1
colors.

Page 1 of 3
Computer Programing Graphics in QBasic Dr. Usman Akmal

Screen Description
Mode
640 × 200 graphics resolution. Also supports 80 × 25 text mode and 2 of 16
2
colors (Black and White).
320 × 200 graphics resolution. Also supports 40 × 25 text mode and 16
7
colors.
640 × 200 graphics resolution. Also supports 80 × 25 text mode and 16
8
colors.
640 × 350 graphics resolution. Also supports 80 × 25 text mode and 16
9
colors.
10 640 × 350 graphics resolution. Also supports 80 × 25 text mode and 2 colors.
11 640 × 480 graphics resolution. Also supports 80 × 25 text mode and 2 colors.
640 × 480 graphics resolution. Also supports 80 × 30 text mode and 16
12
colors.
320 × 200 graphics resolution. Also supports 40 × 25 text mode and 256
13
colors.

PSET Statement

A graphic statement that draws a point on the screen

Syntax

PSET [STEP] (x,y) [,color]

Where

(x,y) specify the screen coordinate where you want to draw a point.

Use the optional STEP keyword indicates that the (x,y) values are relative, not absolute. The
coordinates are treated as distances from the most recent location of the graphics cursor, not
distances from the (0,0) screen coordinate.

If color is omitted, the current foreground color is used.

Example

This example draws a line from (0,0) to (100,100), then erases the line by writing over it with
the background color.

Page 2 of 3
Computer Programing Graphics in QBasic Dr. Usman Akmal

SCREEN

‘Draw a line from (0,0) to (100,100)

FOR I = 0 TO 100

PSET (I, I)

NEXT I

LOCATE 16, 2: INPUT “Press any key to erase the line “, Gar$

‘ Now erase the line

PSET (I-1, I-1), 0

For I = 0 TO 100

PSET STEP (-1, -1), 0

NEXT I

LOCATE 16, 2: PRINT “ “

Page 3 of 3

You might also like