PICO-8 Wiki
fillp( [pat] )
Sets the fill pattern.
A bitfield representing the fill pattern to use.

The fill pattern is part of the draw state. It affects circ(), circfill(), rect(), rectfill(), pset(), and line().

The pattern is a bitfield, a single number that represents a 4x4 pixel pattern. These are the bit values for each pixel in the pattern, in both decimal and hex:

 32768  16384   8192   4096
2048 1024 512 256
128 64 32 16
8 4 2 1
0x8000 0x4000 0x2000 0x1000
0x0800 0x0400 0x0200 0x0100
0x0080 0x0040 0x0020 0x0010
0x0008 0x0004 0x0002 0x0001

The easiest way to represent this pattern in source code is as a binary number literal:


-- A checkerboard pattern:
--     0011
--     0011
--     1100
--     1100

The default pattern is a solid fill (0b0000000000000000). You can reset the pattern by calling fillp() with no arguments.

The color parameter to the drawing functions (such as circfill()) can set two colors, to be used for the on bits (1's) and off bits (0's) of the pattern. The four lower bits of the color value are the "off" (default) color, and the higher bits are the "on" (pattern) color. For example, to draw the off bits as light blue (12, or 0xc) and the on bits as dark blue (1), set the color to 0x1c (28).

fillp(0b0011001111001100) -- or 0x33cc
circfill(60, 60, 10, 0x1c)

Alternatively, you can set the pattern to make the on bits transparent (showing what is drawn underneath). To do this, add 0b0.1, or 0x0.8 if using hex, to the pattern value:

rectfill(0, 0, 127, 127, 3)
fillp(0b0011001111001100.1) -- or 0x33cc.8
circfill(60, 60, 10, 0xc)

Technical notes[]

The current fill pattern is memory-mapped and may be read or written directly:

  • 0x5f31 / 24369: pattern lo byte
  • 0x5f32 / 24370: pattern hi byte
  • 0x5f33 / 24371: transparency bit, 1=transparent, 0=opaque

Predefined pattern values[]

The typeable special characters in the P8SCII range 128-135 are predefined as values that can be used as fillp() patterns. To use these, type Shift with a letter from A to Z in the code editor as the argument. Do not surround the value in quotes: these are predefined global variables with one-symbol names.

-- type shift + m for a face-like pattern

A demo of the predefined special character fill patterns


circfill(40, 40, 10, 8)
circ(40, 40, 10, 7)

circfill(80, 80, 10, 6)
circfill(80, 80, 10, 8)
circ(80, 80, 10, 7)
rectfill(20, 100, 108, 120, 0xe8)

-- get the current fill pattern from its memory-mapped addresses
pattern = peek2(0x5f31)+peek(0x5f33)/2
PICO-8 002

See also[]