BOX

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: BOX
Abbreviation: none
Type: Command
Token code: 220/$DC
Handling routine
in BASIC ROM:
List of all BASIC keywords


Remark: This article describes the BASIC function BOX in Commodore BASIC V3.5 or higher.


-- Draw box at specified position on screen

Type: Command
General Programming-Syntax: BOX [color source], X1,Y1[,X2,Y2][,angle][,paint]]

where:

color source 0=Background color
1=Foreground color
2=Multicolor 1
3=Multicolor 2
x1,y1 Top left corner coordinate (scaled)
x2,y2 Bottom right corner opposite x1,y1, (scaled), default is the PC location.
angle Rotation in clockwise degrees: default is 0 degrees
paint Paint shape with color:

0 = Do not paint 1 = Paint (default=0)

This statement allows the user to draw a rectangle of any size on the screen. Rotation is based on the center of the rectangle. The pixel cursor (PC) is located at x2, y2 after the BOX statement is executed. The color source number must be a zero (0) or one (1) if in standard bit map, or a 2 or 3 if in multicolor bit map mode. Also see the GRAPHIC command for selecting the appropriate graphic mode to be use with the BOX color source number.

The x and y values can place the pixel cursor at absolute coordinates such as (100,100) or at coordinates relative to previous position( + / - x and + / - y) of the pixel cursor such as (+20, - 10). The coordinate of one axis (x or y) can be relative and the other can be absolute. Here are the possible combinations of ways to specify the x and y coordinates:

x,y absolute x, absolute y
+/-x,y relative x, absolute y
x,+/-y absolute x, relativey
+/-x, +/-y relative x, relative y

Also see the LOCATE command for information on the pixel cursor.

Examples[edit | edit source]

BOX 1, +10, +10

Draw a box 10 pixels to the right and 10 down from the current pixel cursor location

BOX 1, 10, 10, 60, 60

Draws the outline of a rectangle.

BOX , 10, 10, 60, 60, 45, 1

Draws a painted, rotated box (a diamond)

BOX , 30, 90, , 45, 1

Draws a filled, rotated polygon.

Any parameter can be omitted but you must include a comma in its place, as in the last two examples.

Note: Wrapping occurs if the degree is greater than 360.


BASIC V3.5 Commands

ABS | ASC | ATN | AUTO | BACKUP | BOX | CHAR | CHR$ | CIRCLE | CLOSE | CLR | CMD | COLLECT | COLOR | CONT | COPY | COS | DATA | DEC | DEF | DELETE | DIM | DIRECTORY | DLOAD | DO | DRAW | DS | DS$ | DSAVE | END | EL | ELSE | ER | ERR$ | EXIT | EXP | FN | FOR | FRE | GET | GET# | GETKEY | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | INSTR | INT | JOY | KEY | LEFT$ | LEN | LET | LIST | LOAD | LOCATE | LOG | LOOP | MID$ | MONITOR | NEW | NEXT | ON | OPEN | PAINT | PEEK | POKE | POS | PRINT | PRINT USING | PRINT# | PUDEF | RCLR | RDOT | READ | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | RLUM | RND | RUN | SAVE | SCALE | SCNCLR | SCRATCH | SGN | SIN | SOUND | SPC | SQR | SSHAPE | STOP | STR$ | SYS | TAB | TAN | TRAP | TROFF | TRON | UNTIL | USR | VAL | VERIFY | VOL | WHILE | WAIT

 
BASIC V7.0 Commands

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 FN | DELETE | DIM | DIRECTORY | DLOAD | DO | DOPEN | DRAW | DS | DS$ | DSAVE | DVERIFY | EL | ELSE | END | ENVELOPE | ER | ERR$ | EXIT | EXP | FAST | FETCH | FILTER | FN | FOR | FRE | GET | GET# | GETKEY | GO64 | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | 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 USING | PRINT# | PUDEF | (QUIT) | RCLR | RDOT | READ | RECORD | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | 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$ | TO | TRAP | TROFF | TRON | USR | VAL | VERIFY | VOL | WAIT | WHILE | WINDOW | WIDTH | XOR