Q(uick)BASIC Statement: PRESET
Quick View
PRESET
A graphics statement that draws a specified point on the screen
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- PRESET [STEP] (x!,y!) [,color%]
- PSET [STEP] (x!,y!) [,color%]
Description/Parameter(s)
STEP | Specifies that the x! and y! are expressed relative to the current graphics cursor location. |
(x!,y!) | The screen coordinates of the pixel to be set. |
color% | A color attribute that sets the pixel color. If color% is omitted, PRESET uses the current background and PSET uses the current foreground color. |
Available color attributes depend on your graphics adapter and screen mode. Coordinate values depend on the graphics adapter, screen mode, and most recent VIEW and WINDOW statements.
Example
This example requires a color graphics adapter.
SCREEN 1
FOR i% = 0 TO 320
PSET (i%, 100)
FOR delay% = 1 TO 100: NEXT delay%
PRESET (i%, 100)
NEXT i%
Syntax
- PRESET [STEP](x,y)[,color]
Description/Parameter(s)
PRESET works exactly like PSET, except that if the color is not specified, the background color is selected.
Argument | Description |
STEP | Indicates that the given x and y coordinates are relative, not absolute. The coordinates are treated as distances from the most recent cursor location, not distances from the (0,0) screen coordinate. |
For example, if the most recent point referenced were (10,10), | |
|
|
would reference the point at (20,15). | |
xcoordinate | The x coordinate of the pixel that is to be set. |
ycoordinate | The y coordinate of the pixel that is to be set. |
color | The color attribute for the specified point. |
If a coordinate is outside the current viewport, no action is taken, nor is an error message given.
Example
This example uses PSET and PRESET to draw a line 20 pixels long, then move the line across the screen from left to right.
SCREEN 1 : COLOR 1,1 : CLS
FOR I = 0 TO 299 STEP 3
FOR J = I TO 20 + I
PSET (J, 50), 2 'Draw the line in new location.
NEXT
FOR J = I TO 20 + I
PRESET (J, 50) 'Erase the line.
NEXT
NEXT
See also:
Syntax
- PRESET [STEP] (x%,y%) [,color&]
Description/Parameter(s)
STEP | Specifies that the (x%,y%) values are expressed relative to the current location of the graphics cursor, rather than in absolute screen coordinate values. |
(x%,y%) | The screen coordinates of the pixel to be set. |
color& | The color of the pixel (default is the current background color). |
The valid range of screen coordinate values and color values depends on the screen mode established by the most recently executed SCREEN statement. |
- STEP indicates that the x and y coordinates are relative, not absolute. The coordinates are treated as distances from the most recent graphics cursor location, not distances from the (0,0) screen coordinate. For example, if the most recent graphics cursor location were (10,10), PRESET STEP (10,5) would draw a point at (20,15).
- If the argument color& is omitted, the current background color is used.
Usage Notes
- PRESET works exactly like PSET, except that if the color is not specified for a PSET statement, the current foreground color is the default.
- If the coordinate is outside the current viewport, no action is taken, nor is an error message given.
Example
This example uses the PSET and PRESET statements to draw a line 20 pixels long, then to move the line across the screen from left to right.
SCREEN 1: COLOR 1, 1: CLS
FOR I = 0 TO 299 STEP 3
FOR J = I TO 20 + I
PSET (J, 50), 2 'Draw the line in new location.
NEXT
FOR J = I TO 20 + I
PRESET (J, 50) 'Erase the line.
NEXT
NEXT
See also: