From QB64 Wiki
Revision as of 07:16, 20 September 2009 by imported>Clippy
Jump to navigation Jump to search

The DRAW graphics statement uses a string value to draw lines on the screen.

Syntax: DRAW draw_string$

  • The draw string can be a draw value in quotation marks or a STRING variable using DRAW function letters.
  • DRAW starting coordinates can be set using PSET, PRESET or other graphic objects.
  • Other graphic objects can be located at or relative to the last DRAW position.
  • Draw strings use letters followed by the number of pixels to move, an angle, coordinate or a color value.
  • Draw strings are flexible with spacing. No spacing is required! DRAW will look for a number value when needed.
  • DRAW statements are not Case sensitive. Use upper or lower case.
  • "C n" designates the color n to be used in the draw statement string following its use.
  • "B" before a line move designates that the line move will be hidden(Blind).
  • "N" before a line move designates that the line will return to the starting position(Null).
  • "M x, y" can move to another coordinate area of the screen. When a + or - sign is used before a coordinate, it is a relative coordinate move similar to using the STEP graphics keyword.
  • "S n" changes the move size of the lines. Default is 4(1 pixel) minimum. "S8" would double the pixel line moves.

  • DRAW uses certain letter designations to create line moves on the SCREEN. Each move is followed by the number of pixels:
  • "U n" makes a line UP n pixels.
  • "D n" makes a line DOWN n pixels.
  • "L n" makes a line LEFT n pixels.
  • "R n" makes a line RIGHT n pixels.
  • "E n" makes a diagonal / line going UP and RIGHT n pixels.
  • "F n" makes a diagonal \ line going DOWN and RIGHT n pixels.
  • "G n" makes a diagonal / LINE going DOWN and LEFT n pixels.
  • "H n" makes a diagonal \ LINE going UP and LEFT n pixels

  • Angles are used to rotate the draw moves following their use. U could become a down move.
  • "A n" can use values of 1 to 3 to rotate up to n 90 degree angles.
  • TA n" can use any n angle from -360 to 0 to 360 to rotate a DRAW (Turn Angle). "TA0" resets to normal.
  • When VARPTR$ is used to create TA angle values use an = sign. "TA=" angle$

Example 1: Placing an octagon shape DRAW across the the screen using PSET.

FOR i% = 1 TO 11
PSET (i% * 50, 100), 15
DRAW "C12 R10 F10 D10 G10 L10 H10 U10 E10"

Example 2: Creating a clock hour frame using Turn Angle.

FOR i = 0 TO 360 STEP 30
angle$ = STR$(i) ' 12 hour circles 30 degrees apart = 360
PSET (175, 250), 6 ' stay at center point of clock
DRAW "TA" + angle$ + "BU100"
CIRCLE STEP(0, 0), 5, 12 ' circle placed at end of blind line
DRAW "P9, 12" ' paint inside of circle

Example 3: Creating a moving second hand for the clock above (SCREEN 12 also).

DO: sec$ = RIGHT$(TIME$, 2) ' get actual seconds from TIME$ function
degree$ = STR$(VAL(sec$) * -6) ' 60 second moves. TA uses negative angle for clockwise
PSET (175, 250), 9 ' stay at clock center
DRAW "TA" + degree$ + "U90" ' up becomes TA directional line
IF INKEY$ <> "" THEN EXIT DO ' any key exit
PSET (175, 250), 0 ' set to erase line
DRAW "TA" + degree$ + "U90" ' erases old second hand line using color 0 from PSET



Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage