BASIC Language Reference Manual >

Overview of Graphics Support in ReadyBASIC

ReadyBASIC supports bitmapped graphics. This means that each pixel can be controlled individually.

The console screen or "canvas" currently has a fixed size.

When accessing pixels, the canvas has a width of 640 pixels and a height of 425 pixels.

Coordinates are addressed in pairs, with the x coordinate named first and the y coordinate named second.

The pixel in the left-hand top corner of the canvas has the coordinates (0, 0). The pixel in the right-hand bottom corner of the canvas has the coordinate (639, 424). In other words, the x coordinate value increases as you go from left to right, and the y coordinate value increases as you go from top to bottom. The direction of the y coordinate is thus the reverse of what you may be accustomed to in mathematics, where the bottom-left corner of a coordinate system is denoted as (0, 0) and the y coordinate value increases as you go upwards on the y axis.

Note that when text is written to the screen, characters are positioned on a grid. The canvas has a width of 80 characters and a height of 25 characters. Each character thus fits within a rectangle 8 pixels wide and 17 pixels tall. Characters have a foreground color, for the shape of the character itself, and a background color, which fills the 8-by-17 rectangle and overwrites any graphics underneath. (Transparent text is currently not supported.)

Graphics primitives commands

Commands that draw pixels to the screen currently include:

  • BAR: Draws a filled rectangle
  • BOX: Draws the outline of a rectangle
  • CIRCLE: Draws a circle
  • LINE: Draws a line between two points


The graphics primitives commands draw to the screen using the current graphics pen color. The PENCOLOR command can be used to set the graphics pen color. When the pen color is set, all subsequent graphics primitives commands use that color, until you change the pen color again.

When ReadyBASIC starts, the default pen color is white, but you should not assume that the pen color is white when your program is run. You should set the color explicitly.

A color is specified as a set of three component primary color intensity values: a value for the intensity of the red component, a value for the intensity of the blue component, and a value for the intensity of the green component. Intensity values can range between 0 (no color) and 255 (maximum intensity). This means that there are 256 * 256 * 256 = 16,777,216 possible colors.

For example, to set the pen color to red, use a red intensity value of 255 and intensity values of 0 from green and blue:

PENCOLOR 255, 0, 0 : REM Set pen graphics color to red

White can be obtained with values 255, 255, 255. Black can be obtained with values 0, 0, 0.

Frequently asked questions

  • How do you clear the screen using a particular color?

    One way is to set the text background color using TEXTBGCOLOR, and the use the CLS command to clear the screen.

    Alternatively, you could set the graphics pen color using PENCOLOR, and then draw a filled rectangle over the entire canvas using the command "BAR 0, 0, 639, 424".

  • How do you draw a single pixel?

    At present, there is no separate command for drawing a single pixel to the screen. To draw a single pixel on the canvas, use the LINE command and repeat the coordinates. (ReadyBASIC recognizes such cases and performs them in an optimized way.) For example, to draw a pixel at coordinates (75, 198), use the command "LINE 75, 198, 75, 198".

  • Is there support for other graphics primitives?

    There is currently no support for other graphics primitives such as arcs and ellipses, but we will consider adding such functionality if there is sufficient demand.

  • Is there a shortcut for referring to commonly-used colors?

    Currently, no, but in the future there are plans to be able to use keywords like ORANGE instead of needing to use value combinations like 255, 190, 190.

Copyright 2006-2008, Kevin Matz, All Rights Reserved.