PICO-8 Wiki
Advertisement
rectfill( x0, y0, x1, y1, [col] )
Draws a filled-in 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 and fill. 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[]

-- fill the whole screen, as if we called cls(1)
rectfill(0, 0, 127, 127, 1)

-- fill the center 96x96 portion of the screen
rectfill(16, 16, 111, 111, 1)

-- draw three filled-in white rectangles at random locations and sizes
color(7)
for x=1,3 do
  rectfill(rnd(128), rnd(128), rnd(128), rnd(128))
end

See also[]

Advertisement