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 "on" color, and the higher bits are the "off" color. For example, to draw the on bits as light blue (12, or 0xc) and the off bits as dark blue (1), set the color to 0x1c (28).

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

Alternatively, you can set the pattern to make the off 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 Edit

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

Examples Edit

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 Edit

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