Overview of Graphics Support in ReadyBASICReadyBASIC 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 commandsCommands that draw pixels to the screen currently include:
ColorsThe 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
Copyright 2006-2008, Kevin Matz, All Rights Reserved. |
|