Available on: all targets

DRAW (program)

The DRAW command allows to draw on the SCREEN. The parameter is either a string constant, or a string variable, containing a set of the draw subcommands. Usually the first action of any drawing is to move to the start point.

M x,y means move to the co−ordinates given by x,y. If you wanto to move to a point, it is usually a good idea to make a "blank" move, that is move without drawing or lifting the pencil off the paper.

If you do not you may get unwanted lines on your drawing, you can use the letter B. Any drawing instruction following the B will be a blank line. BMx,y means move to the x,y without drawing. Having decided the start point, you may now move up (U), down (D), right (R), or Left (L) by as many pixels as you like. The sequence U20R20D20L20 will cause drawing a square.

Apart from vertical and horizontal lines you can also draw diagonal lines. These use the subcommands E,F,G and H, for instance E12 will draw a diagonal line, 12 points long, at 45 degrees from the vertical. All the angles are measured from the vertical as follows: E = 45 degrees, F = 135 degrees, G = 225 degrees and H = 315 degrees. This allows diagonal lines to be drawn in any of 4 directions.

We can change the color by using C. The letter C is followed by a number from 0 to COLOR COUNT, representing the code for one of the available colours.

If the drawing is a bit small, we can scale it up with the S parameter. The S means scale, and allows a drawing, or parts of a drawing to be scaled up or down in units of 1/4 (0.25). So S1 reduces the drawing to 1/4 scale, S2 to 2/4 (half) scale, S8 to 8/4 (twice) scale, and so on. The default setting for scale is 4/4 (i.e. 1, the original size).

Another option available is the angle parameter A. This allows us to rotate all or part of the drawing, as all lines after the A will be drawn with the displacement given by An, where n is a number between 0 and 3, as follows, 0 = 0 degrees, 1 = 90 degrees, 2 = 180 degrees, 3 = 270 degrees.

Finally, the N command has the meaning of no update of drawing position. This is to draw a line as specified but do not use the end of the line as the new position.

SYNTAX

 DRAW instructions


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 DRAW "BM0,0;R10;U10;L10;D10"


Used in:

ABBREVIATION: Dr (program)

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

DRAW (program) ↔ Dr (program)

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS