How to draw a rectangle in PICO-8
22 November, 2022
PICO-8 provides two simple ways to draw rectangles: RECT()
and RECTFILL()
. RECT()
draws an empty rectangle with a 1 pixel wide border, whereas RECTFILL()
draws a filled rectangle. Each function accepts a X and Y position for the top-left and bottom-right corners and a color.
RED=8
X1=60
Y1=60
X2=68
Y2=68
-- DRAWS AN EMPTY RED RECTANGLE IN THE CENTER OF THE SCREEN
RECT(X1,Y1,X2,Y2,RED)
-- DRAWS A FILLED RED RECTANGLE IN THE CENTER OF THE SCREEN
RECTFILL(X1,Y1,X2,Y2,RED)
If you’re drawing a lot of shapes with the same color, you may omit the color parameter by setting the current color with the COLOR()
function.
RED=8
FUNCTION _DRAW()
COLOR(RED)
RECTFILL( 0, 0,10,10)
RECTFILL(20,20,30,30)
RECTFILL(40,40,50,50)
END