Color
Jump to navigation
Jump to search
color( [col] )
- Sets the draw color in the draw state.
- col
-
- The color number. Default is 6 (light gray).
Many graphics functions accept an optional color argument. When this argument is omitted, the current color of the draw state is used by default. The color()
function sets this color.
The color number corresponds to the PICO-8 palette, a value between 0 and 15. See Graphics for an illustrated table of colors.
When you provide an explicit color argument to a graphics function, PICO-8 changes the draw color to that color.
The color()
function honors the alternate palette set by pal()
.
The previous color is returned when calling color()
, allowing it to be saved and restored if needed.
Technical notes
The current pen color is memory-mapped and may be read or written directly with peek()
and poke()
:
- 0x5f25 / 24357: current pen color
Examples
cls()
color(7) -- white
circfill(20, 20, 10)
circfill(60, 60, 10)
color(8) -- red
circfill(20, 60, 10)
circfill(60, 20, 10)
pal(7, 10) -- white -> yellow
color(7)
circfill(20, 100, 10)
circfill(60, 100, 10)
-- get the current color from its memory-mapped address
cur_color=peek(0x5f25)