PalF Class¶
The PalF class is the main class for parsing and working with Zoo Tycoon 1 palette files.
Source code in include/ztalib/PalF.h and src/PalF.cpp.
Import¶
Import the PalF class as so:
class PalF¶
class PalF
{
struct Color
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
PalF();
int load(std::string fileName);
void save(std::string fileName);
std::string location();
void location(std::string loc);
uint32_t locationSize();
void locationSize(uint32_t size);
int colorModel();
void colorModel(int model);
std::vector<Color> colors() const;
void colors(const std::vector<Color>& newColors);
Color getColor(int index);
};
Example¶
struct PalF::Color¶
Represents a single color in the palette. Contains red, green, blue, and alpha components as 8-bit unsigned integers.
meth load¶
Load a PalF file from disk. Returns 0 on success, non-zero on failure.
Example
meth save¶
Save the current palette data to a PalF file on disk.
Example
meth location¶
Get or set the location of the palette file. This is the file path used when loading the palette.
Example
meth locationSize¶
Get or set the size of the palette file. This is the number of bytes in the file. Byte count must be accurate for future encoding of the palette file to work correctly.
Example
meth colorModel¶
Get or set the color model used when parsing the palette file. 0 == RGBA, 1 == BGRA.
Example
meth colors¶
Get or set the colors in the palette as a vector of Color structs.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
std::vector<PalF::Color> newColors = {
{255, 0, 0, 255}, // Red
{0, 255, 0, 255}, // Green
{0, 0, 255, 255} // Blue
};
pal.colors(newColors);
std::vector<PalF::Color> colors = pal.colors();
for (size_t i = 0; i < colors.size(); ++i) {
const auto& color = colors[i];
std::cout << "Color " << i << " - R: " << (int)color.r
<< " G: " << (int)color.g
<< " B: " << (int)color.b
<< " A: " << (int)color.a << std::endl;
}
}
from pyzta import PalF
pal = PalF()
new_colors = [
PalF.Color(255, 0, 0, 255), # Red
PalF.Color(0, 255, 0, 255), # Green
PalF.Color(0, 0, 255, 255) # Blue
]
pal.colors(new_colors)
colors = pal.colors()
for i, color in enumerate(colors):
print(f"Color {i} - R: {color.r} G: {color.g} B: {color.b} A: {color.a}")
meth getColor¶
Get the color at the specified index in the palette. Returns a Color struct containing the RGBA values of the color.
Example