Home > CBM > BASIC > Keywords > Draw
180 Subpages: (divide), (equal), (less), (minus), (more), (multiply), (plus), (power), Abs, And, Append, Asc, Atn, Auto, Backup, Bank, Begin, Bend, Bload, Boot, Box, Bsave, Bump, Catalog, Char, Chr, Circle, Close, Clr, Cmd, Collect, Collision, Color, Concat, Cont, Copy, Cos, Data, Dclear, Dclose, Dec, Def, Delete, Dim, Directory, Dispose, Dload, Do, Dopen, Ds, Ds string, Dsave, Dverify, El, Else, End, Envelope, Er, Err, Exit, Exp, Fast, Fetch, Filter, Fn, For, Fre, Get, Get num, Getkey, Go, Gosub, Goto, Graphic, Gshape, Header, Help, Hex, If, Input, Input num, Instr, Int, Joy, Key, Left, Len, Let, List, Load, Locate, Log, Loop, Mid, Monitor, Movspr, New, Next, Not, Off, On, Open, Or, Paint, Peek, Pen, Pi, Play, Pointer, Poke, Pos, Pot, Print, Print num, Pudef, Quit, Rclr, Rdot, Read, Record, Rem, Rename, Renumber, Restore, Resume, Return, Rgr, Right, Rlum, Rnd, Rreg, Rspcolor, Rsppos, Rsprite, Run, Rwindow, Save, Scale, Scnclr, Scratch, Sgn, Sin, Sleep, Slow, Sound, Spc, Sprcolor, Sprdef, Sprite, Sprsav, Sqr, Sshape, St, Stash, Step, Stop, Str, Swap, Sys, Tab, Tan, Tempo, Then, Ti, Ti string, To, Trap, Troff, Tron, Until, Using, Usr, Val, Verify, Vol, Wait, While, Width, Window, Xor

Keyword
AbbreviationToken (hex)Version(s)Classification
DRAWD{Shift+R}E53.5, 7.0Command and Statement
PUDEFP{Shift+U} E5 4.7 Command and Statement

Syntax 
DRAW [ colorSource ] [ { TO | , } { [ + | - ] xVal [ , [ + | - ] yVal ] distance ; angle } ] ...
 
ParametersTypeLegal Value(s)Default ValueNote(s)
colorSourceInteger
0 or 1 (high-res)
0 to 3 (multi-color)
1
The actual color on-screen depends
on the colorSource assignment by COLOR
xValInteger* -32768 to +32767 pixel cursor X rectangular X ordinate or offset for a point
yVal Integer* -32768 to +32767 pixel cursor Yrectangular Y ordinate or offset for a point 
distanceInteger* -32768 to +32767 polar distance for a point
angleUnsigned Integer 0 to 65535 undefinedpolar angle for a point
*Due to a bug in the original C128 ROMs (start-up message says (c)1985), only positive/unsigned values of 0 to 65535 may be used.
 
 
Purpose 
Plot a set of points and/or line segments on the bitmap screen.

 
 
Remarks 
All parameters are optional.  Without any, DRAW will plot a single pixel at the pixel cursor (the last point calculated in the previous bitmap command).
 
Following the optional colorSource is a set of zero or more points.  If the point is introduced with a comma (,) then a single pixel is plotted; otherwise (the point is introduced with the TO preposition) a line segment is plotted from the pixel cursor to the new specified point.  A specified coordinate will be effected by SCALE if it is active.  The resulting values may be off-screen, but are acceptable as long as they are legal as shown above.  After each single point or line segment is plotted on the bitmap, the pixel cursor is updated (to the new point) so that the next point may refer to it; this allows you to easily draw a complex figure consisting of many connected lines and/or disconnected lines and/or isolated points.
 
point specified as a polar coordinate will always be relative to the pixel cursor.  A point specified in rectangular form will normally be an absolute coordinate (independ of the pixel cursor), but using a + or - in front of the xVal or yVal will make that ordinate relative to the pixel cursor.  The x and y ordinates are processed independantly; either, neither, or both ordinates of the rectangular coordinate may be in relative form (whichever use a leading + or -).  Note these must be literal + and - characters in the command/statement.  So if you have a variable X with a negative value (like -10) then it will be used an absolute coordinate unless you preced it with + or - sign.  You normally wouldn't put a - sign unless you want to reverse the direction of the variable.  So, for this example, use +X for a relative ordinate.  As opposed to a variable, if you want to enter a literal negative value (for an absolute ordinate), you must enclose it in parentheses; otherwise it would interpreted as a relative ordinate.  Sorry if that is confusing!  If so, you need to play with relative and absolute coordinates to see clearly what I mean.
 
The width plotted on screen of each dot (for a single point) or for all dots (for a line-segment) is controlled by a secret BASIC variable.  That secret variable can be set with WIDTH.  If it is 1, each dot will be 1 pixel wide; if it is 2, each dot will be 2 pixels wide.
  
Any floating-point numbers will first be converted to integers (see INT).  If any value is out-of-range (see above) an ILLEGAL QUANTITY ERROR is generated.  If no bitmap has been setup (see GRAPHIC), a NO GRAPHICS AREA is generated.
 
Example of optional colorSource and optional point:
DRAW 1 : REM draw a point at the pixel cursor

READY.
DRAW , 60,60 : REM draw a point at 60,60

READY.
DRAW TO 100,100 : REM line from 60,60 to 100,100
 
Example of relative rectangular and polar coordinate:
DRAW 1,60,60: DRAW 1, +10,-10 : REM DRAW 1, 70,50 = 60+10, 60-10

READY.
DRAW 1, (+10),(-10) : REM DRAW at absolute coordinate (10,-10)

READY.
DRAW 1,60,60: DRAW 1, 20; 30 : REM ~DRAW 1, 70,43 = 60+20*SIN(30), 60-20*COS(30)
 
Example of line segments:
DRAW 1, 60,60 TO 100,100 : REM single line segment

READY.
DRAW 1, 60,60 TO 60,0 TO 0,60 : REM two connected line segments (a "lambda")

READY.
DRAW 1, 0,70 TO 140,70, 70,0 TO 70,140 : REM two independant line segments (a cross)
 
Compare With 
 
See Also 

© H2Obsession, 2014