Topic : The GFA-Basic Compendium
Author : GFA Systemtechnik GmbH
Version : GFABasic.HYP v2.98 (12/31/2023)
Subject : Documentation/Programming
Nodes : 899
Index Size : 28056
HCP-Version : 3
Compiled on : Atari
@charset : atarist
@lang :
@default : Document not found
@help : Help
@options : +g -i -s +z
@width : 75
@hostname : STRNGSRV
@hostname : CAB
@hostname : HIGHWIRE
@hostname : THING
View Ref-FileDRAW expression
DRAW(i)
SETDRAW x,y,a
i, x, y, a: iexp
expression: a mixture of sexp and aexp, a sexp must be first and the individual
parameters must be separated by a comma (,), semicolon (;), or an
apostrophe (')
With DRAW an imaginary pen is moved over the screen and draws relative to the
last point. The DRAW command's structure resembles the turtle-graphic commands
of the programming language Logo. The parameters of the DRAW command can
contain a large number of individual commands, which are all passed to the
command in the form of a string. Parts of the expression can be given in
floating-point format, allowing for the use of variables. In this 'Logo like'
convention, an imaginary 'pen' is controlled by means of the graphic commands
and its movement over the 'paper' creates the graphic image. The statement
below is given as an example of how these commands may be used:
DRAW "FD 100 RT ",angle," PU BK ";50
The available commands are:
FD n ForwarD Moves the pen 'n' pixels forward.
BK n BacKward Moves the pen 'n' pixels backwards.
SX x Scale X Scales the 'pen movement' for FD and BK by the
SY y Scale Y specified factor. The scale with SX an SY works only
with the commands FD and BK. With SX0 or SY0 the scale
is switched off. This is quicker than scaling with the
factor 1 (SX1, SY1).
LT a Left Turn Turns the pen to the left through the specified angle
'a', this being given in degrees.
RT a Right Turn Turns the pen as LT, but to the right.
TT a Turn To Turns the pen to the absolute angle 'a'. (See notation
below:)
0
|
|
270-Zero point-90
|
|
180
The data for the angle, 'a' is specified in degrees.
MA x,y Move Absolute Moves the pen to the absolute coordinates for x and y.
DA x,y Draw Absolute Moves the pen to the absolute coordinates for x and y
and draws a line in the current color from the last
position to the point (x,y).
MR x,y Move Relative Moves the pen position in the x and y directions
releative to the last position.
x,y Draw Relative Moves the pen by the specified displacement relative to
its last position and draws a line in the current color
from the last position to this point.
CO c COlor Sets the drawing color to 'c' (see COLOR command).
PU Pen Up Lift the pen up from the paper.
PD Pen Down Lowers the pen down onto the paper.
The command SETDRAW x,y,a is an abbreviation for the expression
DRAW "MA ";x,y;"TT ";a.
Additionally the following pen interrogation functions are available:
Index Description Default
DRAW(0) x-position 0
DRAW(1) y-position 0
DRAW(2) Angle in degrees 0
DRAW(3) x-axis scale factor 0
DRAW(4) y-axis scale factor 0
DRAW(5) Pen flag (-1=PD, 0=PU) -1
Note: All of these functions return floating point values.
Example:
DRAW "ma 160,200 tt 0" !start at 160,200 and angle 0
FOR i&=3 TO 10
polygon(i&,90) !draws a Polygon with i& corners
NEXT i&
'
PROCEDURE polygon(n&,r&) !n&=number of corners and r&=length of sides
LOCAL i&
FOR i&=1 TO n&
DRAW "fd ",r&," rt ",360/n&
NEXT i&
RETURN
--> Draws a set of polygons with an increasing number of sides.
FOR i=0 TO 639 STEP 8
SETDRAW 320,200,i
GRAPHMODE 3
DRAW "fd 45 rt 90 fd 45 rt 90 fd 45 rt 90 fd 45"
DRAW "bk 90 rt 90 bk 90 rt 90 bk 90 rt 90 bk 90"
GRAPHMODE 1
DRAW "fd 45 rt 90 fd 45 rt 90 fd 45 rt 90 fd 45"
DRAW "bk 90 rt 90 bk 90 rt 90 bk 90 rt 90 bk 90"
NEXT i
--> Forms a shape from two small squares and two large ones, and then rotates
it through 360 degrees.
l%=48
' Square:
DRAW "ma 60,100 tt 45"
DRAW "fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90"
' Diamond, tall:
DRAW "mr 100,0 tt 45"
DRAW "sx 0.5 sy 0"
DRAW "fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90"
' Diamond, wide:
DRAW "mr 100,0 tt 45"
DRAW "sx 0 sy 0.5"
DRAW "fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90"
' Diamons, large and tall
DRAW "mr 100,0 tt 45"
DRAW "sx 3 sy 2"
DRAW "fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90 fd ",l%,"rt 90"
--> Draws a square at an angle, followed by three diamonds of various sizes.
These diamonds are produced by changing the x and y scales and redrawing
the original square.
SETDRAW 100,100,90
DRAW "PU FD 40 PD FD 40"
PRINT DRAW(0) !x-coordinate
PRINT DRAW(5) !Pen flag
--> A horizontal line is drawn and the numbers 180 and -1 printed.
Memo: y=DRAW(x) does not do a proper range check on the value of x.
Any value over 5 for x returns index 5.
DRAW "XX" does not check for invalid commands. In some cases they are
ignored or it crashes the editor.
Example: DRAW "BX 8" !crashes the editor
Spaces, commas, and semicolons are ingnored within string parameters:
DRAW "PU FD 40,PD;FD 40"
| | |
space comma semicolon
v_pline()+