2.15.1
Functions
Palette

Color palette resources management for sprites and background layers. More...

Description

Color palette resources management for sprites and background layers.

Functions

TLN_Palette TLN_CreatePalette (int entries)
 Creates a new color table. More...
 
TLN_Palette TLN_LoadPalette (const char *filename)
 Loads a palette from a standard .act file. More...
 
TLN_Palette TLN_ClonePalette (TLN_Palette src)
 Creates a duplicate of the specified palette. More...
 
bool TLN_SetPaletteColor (TLN_Palette palette, int color, uint8_t r, uint8_t g, uint8_t b)
 Sets the RGB color value of a palette entry. More...
 
bool TLN_MixPalettes (TLN_Palette src1, TLN_Palette src2, TLN_Palette dst, uint8_t factor)
 Mixes two palettes to create a third one. More...
 
bool TLN_AddPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by adding the provided color value to the selected range. The result is always a brighter color. More...
 
bool TLN_SubPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by subtracting the provided color value to the selected range. The result is always a darker color. More...
 
bool TLN_ModPaletteColor (TLN_Palette palette, uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t num)
 Modifies a range of colors by modulating (normalized product) the provided color value to the selected range. The result is always a darker color. More...
 
uint8_t * TLN_GetPaletteData (TLN_Palette palette, int index)
 Returns the color value of a palette entry. More...
 
int TLN_GetPaletteNumColors (TLN_Palette palette)
 Returns the number of color entries in the given palette. More...
 
bool TLN_DeletePalette (TLN_Palette palette)
 Deletes the specified palette and frees memory. More...
 

Function Documentation

◆ TLN_CreatePalette()

TLN_Palette TLN_CreatePalette ( int  entries)

Creates a new color table.

Parameters
entriesNumber of color entries (typically 256)
Returns
Reference to the created palette or NULL if error

◆ TLN_LoadPalette()

TLN_Palette TLN_LoadPalette ( const char *  filename)

Loads a palette from a standard .act file.

Parameters
filenameACT file containing the palette to load
Returns
A reference to the newly loaded palette, or NULL if error
Remarks
Palettes are also automatically created when loading tilesets and spritesets. Use the functions TLN_GetTilesetPalette() and TLN_GetSpritesetPalette() to retrieve them.
See also
TLN_GetTilesetPalette(), TLN_GetSpritesetPalette()

◆ TLN_ClonePalette()

TLN_Palette TLN_ClonePalette ( TLN_Palette  src)

Creates a duplicate of the specified palette.

Parameters
srcReference to the palette to clone
Returns
A reference to the newly cloned palette, or NULL if error
See also
TLN_CreatePalette()

◆ TLN_SetPaletteColor()

bool TLN_SetPaletteColor ( TLN_Palette  palette,
int  index,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets the RGB color value of a palette entry.

Parameters
paletteReference to the palette to modify
indexIndex of the palette entry to modify (0-255)
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)

◆ TLN_MixPalettes()

bool TLN_MixPalettes ( TLN_Palette  src1,
TLN_Palette  src2,
TLN_Palette  dst,
uint8_t  factor 
)

Mixes two palettes to create a third one.

Parameters
src1Reference to the first source palette
src2Reference to the second source palette
dstReference to the target palette
factorInteger with mixing factor. 0=100% src1, 255=100% src2, 128=50%/50%

◆ TLN_AddPaletteColor()

bool TLN_AddPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by adding the provided color value to the selected range. The result is always a brighter color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify

◆ TLN_SubPaletteColor()

bool TLN_SubPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by subtracting the provided color value to the selected range. The result is always a darker color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify

◆ TLN_ModPaletteColor()

bool TLN_ModPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)

Modifies a range of colors by modulating (normalized product) the provided color value to the selected range. The result is always a darker color.

Parameters
paletteReference to the palette to modify
rRed component of the color (0-255)
gGreen component of the color (0-255)
bBlue component of the color (0-255)
startindex of the first color entry to modify
numnumber of colors from start to modify

◆ TLN_GetPaletteData()

uint8_t* TLN_GetPaletteData ( TLN_Palette  palette,
int  index 
)

Returns the color value of a palette entry.

Parameters
paletteReference to the palette to get the color
indexIndex of the palette entry to obtain (0-255)
Returns
32-bit integer with the packed color in internal pixel format RGBA

◆ TLN_GetPaletteNumColors()

int TLN_GetPaletteNumColors ( TLN_Palette  palette)

Returns the number of color entries in the given palette.

Parameters
paletteReference to the palette to query
Returns
number of color entries

◆ TLN_DeletePalette()

bool TLN_DeletePalette ( TLN_Palette  palette)

Deletes the specified palette and frees memory.

Parameters
paletteReference to the palette to delete
Remarks
Don't delete a palette currently attached to a layer or sprite!