Skip to main content

Transformations

For transforming the colors and the coordinates' system.

pal

Map a color in the palette to another color.

There are 2 palettes: The Images' Palette which affects images only. And the Drawing Palette which affects all other graphics functions.

Map a color to another one

pal(colorIdA, colorIdB, palette)
ParameterTypeDefaultNote
colorIdAnumber, boolean⚠️ requiredinteger in range [0, 15]. the color to replace. or false for all.
colorIdBnumber⚠️ requiredinteger in range [0, 15]. the color which will replace color A.
palettenumber, boolean, nilnil0: Drawing Palette. 1: Images Palette. nil/false: both.

Reset a color to it's default

pal(colorId, false, palette)
ParameterTypeDefaultNote
colorIdnumber⚠️ requiredinteger in range [0, 15]
falsebooleanℹ️ literal
palettenumber, boolean, nilnil0: Drawing Palette. 1: Images Palette. nil/false: both.

Reset the whole palette

pal(false, false, palette)
ParameterTypeDefaultNote
falsebooleanℹ️ literal
falsebooleanℹ️ literal
palettenumber, boolean, nilnil0: Drawing Palette. 1: Images Palette. nil/false: both.

palt

Make a specific color transparent or not. By default the color 0 is transparent.

This only affects images.

Set the transparency of a color

palt(colorId, isTransparent)
ParameterTypeDefaultNote
colorIdnumber⚠️ requiredinteger in range [0, 15].
isTransparentbooleanfalse

Reset the colors to their default

Which is opaque for all colors except 0, which is considered transparent.

palt()

colorPalette

Read and modify the real RGB values of a color in the palette.

Get the RGB values of a color

r, g, b = colorPalette(colorId)
ParameterTypeDefaultNote
colorIdnumber⚠️ requiredinteger in range [0, 15]
ReturnTypeNote
rnumberred channel, integer in range [0, 255].
gnumbergreen channel, integer in range [0, 255].
bnumberblue channel, integer in range [0, 255].

Set the RGB values of a color

colorPalette(colorId, r, g, b)
ParameterTypeDefaultNote
colorIdnumber⚠️ requiredinteger in range [0, 15]
rnumber⚠️ requiredred channel, integer in range [0, 255].
gnumber⚠️ requiredgreen channel, integer in range [0, 255].
bnumber⚠️ requiredblue channel, integer in range [0, 255].

Reset the palette colors to their defaults

Which is the PICO-8 palette.

colorPalette()

cam

Transform the drawing operations.

The transforming operations sums up, to reset check the fifth usage of this function.

Translate (shift) coordinates origin

Shift all drawing operations.

cam("translate", x, y)
ParameterTypeDefaultNote
'translate'stringℹ️ literal
xnumber⚠️ required
ynumber⚠️ required

Scale coordinates

Scale all the drawing operations.

cam("scale", scaleX, scaleY)
ParameterTypeDefaultNote
'scale'stringℹ️ literal
scaleXnumber⚠️ required1 to preserve scale.
scaleYnumber⚠️ required1 to preserve scale.

Rotate around coordinates origin

cam("rotate", angle)
ParameterTypeDefaultNote
'rotate'stringℹ️ literal
anglenumber⚠️ requiredin radians.

Shear coordinates

cam("shear", shearX, shearY)
ParameterTypeDefaultNote
'shear'stringℹ️ literal
shearXnumber⚠️ required
shearYnumber⚠️ required

Reset all the transformations

Reset all the transformations done back to their original state.

cam()

clip

Set the region that can be drawn on.

Enable clipping

The arguments can be passed in a table.

clip(x, y, width, height)
ParameterTypeDefaultNote
xnumber⚠️ required
ynumber⚠️ required
widthnumber⚠️ required
heightnumber⚠️ required

Disable clipping

clip()