Watson Graphics Language recognizes seven kinds of instructions: assignment,
color, draw, erase, increment, decrement, and loop.
Assignment - Assignment statements in
WGL are often used to specify the size, shape, location, or orientation of an
object. The format of an assignment statement in WGL is: VARIABLE : = EXPRESSION
where VARIABLE is replaced by a variable of some particular type
and EXPRESSION is replaced by an expression of the same type.
Color - The color statement is used to
select a drawing color. This statement does not actually place anything on the
screen. It is analogous to picking up a pen of a particular color. All subsequent
draw commands will use the specified color until it is changed by issuing another
color command. The format of the color statement is color(COLOR_NAME)
where COLOR_NAME is a constant of type color.
Draw - The draw statement is used to display
an object of type point, line, circle, or polygon, in the drawing area. An object
must be completely defined before it can be drawn. The format of the draw statement
is draw(OBJECT) where OBJECT is a variable of
type point, line, circle, or polygon. Constants can not be directly drawn; neither
can distances, colors, and counters.
Erase - The statement is used to erase
or "un-draw" an object. Essentially, erase is just a draw statement where the object
is drawn in white. Since white is the background color of the drawing area used
in the Watson Graphics Lab, an object that has been previously drawn appears to
be "erased" by this statement. The format of the erase statement is erase(OBJECT)
where OBJECT is a variable of type point, line, circle, or polygon.
Increment - The increment statement increases
the value held in a distance variable by some constant amount. The format of the
increment statement is increment(DISTANCE, AMOUNT) where DISTANCE is replaced by a distance variable and AMOUNT
is replaced by a distance constant.
Decrement - The decrement statement is
similar to the increment statement, except that instead of increasing the value
held in a distance variable, it decreases that value by some constant amount.
The format of this statement is decrement(DISTANCE, AMOUNT) where
DISTANCE is replaced by a distance variable and AMOUNT
is replaced by a distance constant.
Loop - The loop statement is used to repeat
a group of statements a fixed number of times. Loops are useful for drawing a
series of similar objects and for creating simple animation sequences. The format
of the loop statement is:
repeat COUNTER times
loop
<one or more statements>
endloop
where COUNTER is replaced by a non-negative integer
constant in the range 1 to 99 and <one or more statements> is replaced
by some number of WGL statements.