Functions
Palette

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

Description

Functions

TLNAPI TLN_Palette TLN_CreatePalette (int entries)
 Creates a new color table. More...
 
TLNAPI TLN_Palette TLN_LoadPalette (const char *filename)
 Loads a palette from a standard .act file. More...
 
TLNAPI TLN_Palette TLN_ClonePalette (TLN_Palette src)
 Creates a duplicate of the specified palette. More...
 
TLNAPI 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...
 
TLNAPI bool TLN_MixPalettes (TLN_Palette src1, TLN_Palette src2, TLN_Palette dst, uint8_t factor)
 Mixes two palettes to create a third one. More...
 
TLNAPI 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...
 
TLNAPI 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...
 
TLNAPI 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...
 
TLNAPI uint8_t * TLN_GetPaletteData (TLN_Palette palette, int index)
 Returns the color value of a palette entry. More...
 
TLNAPI bool TLN_DeletePalette (TLN_Palette palette)
 Deletes the specified palette and frees memory. More...
 

Function Documentation

TLNAPI TLN_Palette TLN_CreatePalette ( int  entries)
Parameters
entriesNumber of color entries (typically 256)
Returns
Reference to the created palette or NULL if error
TLNAPI TLN_Palette TLN_LoadPalette ( const char *  filename)
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()
TLNAPI TLN_Palette TLN_ClonePalette ( TLN_Palette  src)
Parameters
srcReference to the palette to clone
Returns
A reference to the newly cloned palette, or NULL if error
See also
TLN_CreatePalette()
TLNAPI bool TLN_SetPaletteColor ( TLN_Palette  palette,
int  index,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)
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)
TLNAPI bool TLN_MixPalettes ( TLN_Palette  src1,
TLN_Palette  src2,
TLN_Palette  dst,
uint8_t  factor 
)
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%
TLNAPI bool TLN_AddPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)
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
TLNAPI bool TLN_SubPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)
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
TLNAPI bool TLN_ModPaletteColor ( TLN_Palette  palette,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  start,
uint8_t  num 
)
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
TLNAPI uint8_t* TLN_GetPaletteData ( TLN_Palette  palette,
int  index 
)
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
TLNAPI bool TLN_DeletePalette ( TLN_Palette  palette)
Parameters
paletteReference to the palette to delete
Remarks
Don't delete a palette currently attached to a layer or sprite!