What you will learn in this lesson
Welcome back to school after the holidays! In Module 1, you learn about simple graphics using the Line, Circle and Pset Commands. But here in Module 2, the standard required here is much higher! We are going to learn a
much more sophisticated and accurate way of drawing objects: The Draw Command.
The Draw Command
Syntax: Draw commandstring$
The draw command is by far the easiest and most versatile graphics command.
It does not involve complicated bitmap loading operations, instead extracting the graphic from a commandstring.
The downside of this command are the complicated elements in the command string.
To a beginner, these commands may be completely baffling.
However, experienced users of the draw command would find themselves able to draw pictures simply by typing. Thus, one needs practice in order to master the draw command.

The commandstring is a string expression consisting of the single letter commands and their values. It can be referred to by a string variable name or can simply be a string of characters appended to the draw command. The commandstring can be thought of as mini program to control a robot that draws pictures. The "robot", technically known as a cursor, can change its colors, move to a new position during the process of drawing a line or even rotate part of the canvas it is drawing on.

D[n%] Moves cursor down n% units.
E[n%] Moves cursor up and right n% units.
F[n%] Moves cursor down and right n% units.
G[n%] Moves cursor down and left n% units.
H[n%] Moves cursor up and left n% units.
L[n%] Moves cursor left n% units.
M[{+|-}]x%,y% Moves cursor to point x%,y%. If x% is preceded
by + or -, moves relative to the current point.
R[n%] Moves cursor right n% units.
U[n%] Moves cursor up n% units.
in other words:
H U E
L * R
G D F
These letters tell the cursor which direction to move in.
[B] Optional prefix that moves cursor without drawing.
( The ficticious robot raises its drawing pen and moves somewhere.)
[N] Optional prefix that draws and returns cursor to its original position.
(The robot follows the command and returns to its previous position)
Now, all the lines the robot has drawn are slightly higher than the paper.
Pn1%,n2% Sets the paint fill and border colors of an object
(n1% is the fill-color attribute, n2% is the
border-color attribute).
Our robotic friend will "spill" a paint bucket of n1% coloured paint that fills all areas enclosed by lines of the color n2%
An% Rotates an object n% * 90 degrees
(n% can be 0, 1, 2, or 3).
TAn% Turns an angle n% degrees
(-360 through 360).
Our able robot is also very smart, unlike some of the human species. If its reads the command TA, it will rotate the lines anticlockwise by n% degrees.
Cn% Sets the drawing color (n% is a color attribute).
This makes our "robot" change the colour of its drawing pen.
Sn% Determines the drawing scale by setting the length
of a unit of cursor movement. The default n% is 4,
which is equivalent to 1 pixel.
The intrepid artist-robot resizes the canvas, with the lines on it. You have learnt the Draw command! Though whether you can use or master it is another matter. . .all I can say is that it comes with practice.
Well, I suppose that's all for the lesson. Now for the Assignment!
QB Assignment
Today's Assignment is simply to have fun, experiment, and practise using the Draw command!
Have fun!
[ Home ] [ Intro ] [ Lessons ] [ Library ] [ Reference ] [ About ]
This Webpage is ThinkQuest entry Unknown.
Email: lccorp1997@hotmail.com
This Webpage is Designed for Netscape Navigator 3.0 and MSIE 3.0
We prefer a 24-bit True Color mode with 640x480 screen mode.
This Webpage created for Thinkquest 1998.