FANDOM


rect( x0, y0, x1, y1, [col] )
Draws an empty rectangle shape.
x0
The x coordinate of the upper left corner.

y0
The y coordinate of the upper left corner.

x1
The x coordinate of the lower right corner.

y1
The y coordinate of the lower right corner.

col
The color of the rectangle border. If omitted, the color from the draw state is used.

This draws a rectangle shape parallel to the screen borders.

It's important to note that the coordinates are inclusive, which is to say PICO-8 will render pixels at the right and bottom coords. In many APIs, x1 and y1 would be the first pixels which are not drawn, but on PICO-8, they are the last pixels which are drawn.

Examples Edit

-- draw a border around the whole screen
rect(0, 0, 127, 127, 1)
 
-- draw a border inset by 16 pixels
rect(16, 16, 111, 111, 1)
 
-- draw three empty white rectangles at random locations and sizes
color(7)
for x=1,3 do
  rect(rnd(128), rnd(128), rnd(128), rnd(128))
 
end

See also Edit

Community content is available under CC-BY-SA unless otherwise noted.