LINE - QB64 Wiki


From QB64 Wiki

Jump to: navigation, search

The LINE statement is used in graphics SCREEN modes to create lines or boxes.


LINE [STEP] [(column1, row1)]-[STEP] (column2, row2), color[, [{B|BF}], style%]


  • Can use STEP keyword for graphics coordinates relative to the previously placed object before either set of coordinates.
  • The optional parameters (column1, row1) set the first coordinate or use the last previous object coordinate when omitted.
  • The dash and second coordinate parameters (column2, row2) must be designated to complete the line or box.
  • The INTEGER color attribute or LONG _RGB32 32 bit color value sets the line, box or full box color.
  • Optional B creates a box outline using the start and end coordinates as diagonal corners. BF creates a filled box.
  • The style signed INTEGER value sets 16 line pixels with varying patterns when using values from 1 (2 ^ 0) to -32768 (2 ^ 15)


  • Creates a colored line from coordinate1 to coordinate2 if the box options(B or BF) are omitted. Can be drawn partially off screen.
  • B creates a box outline with each side parallel to the program screen sides. BF creates an identical filled box.
  • B can be used with style to create a dash pattern on all 4 box sides. BF cannot be used with style.
  • Both commas are required before the style value. Dots are created where the style value's bits are on, MSB on left.
  • The QB64 and QB graphic cursor is set to the center of the program window on program start for STEP relative coordinates.
  • LINE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only!

Example 1: Following one line with another by omitting the second line's first coordinate parameter bracket entirely:

SCREEN 12 LINE (100, 100)-(200, 200), 10 'creates a line LINE -(400, 200), 12 'creates a second line from end of first END

Explanation: The full equivalent LINE statement would be: LINE(200, 200)-(400, 200), 12

Example 2: Creating styled lines and boxes with the LINE statement. Different style values create different dashed line spacing.

SCREEN 12 LINE (100, 100)-(300, 300), 10, , 63 'creates a styled line LINE (100, 100)-(300, 300), 12, B, 255 'creates styled box shape END

Explanation: The first diagonal dashed green line bisects the red dashed square from Top Left to Bottom Right Corners.

Example 3: The style value sets each 16 pixel line section as the value's bits are set on or off:

SCREEN 13 _FULLSCREEN 'required in QB64 only _DELAY 5 FOR i% = 1 TO 2 ^ 15 'use exponential value instead of -32768 COLOR 15:LOCATE 10, 5: PRINT i%; LINE (10, 60)-(300, 60), 0 'erase previous lines LINE (10, 60)-(300, 60), 12, , i% tmp$ = "" FOR b% = 15 TO 0 STEP -1 'create binary text value showing bits on as , off as space IF i% AND 2 ^ b% THEN tmp$ = tmp$ + CHR$(219) ELSE tmp$ = tmp$ + SPACE$(1) NEXT COLOR 12:LOCATE 10, 20: PRINT tmp$; IF INKEY$ <> "" THEN EXIT FOR 'any key exit _DELAY .001 'set delay time as required NEXT

Explanation: The style value's Most Significant Bit (MSB) is set to the left with LSB on right as 16 text blocks are set on or off.

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Personal tools