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. The bits correspond to squares in the pattern:

32768 16384 8192 4096
2048 1024 512 256
128 64 32 16
8 4 2 1

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).

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 to the pattern value:

rectfill(0, 0, 127, 127, 3)
circfill(60, 60, 10, 0xc)

Technical notes Edit

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

  • 0x5f31: pattern lo byte
  • 0x5f32: pattern hi byte
  • 0x5f33: 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
PICO-8 002

See also Edit