|
Porytiles
|
Represents a hardware palette after packing with accumulated colors and assigned tiles. More...
#include <packed_palette.hpp>
Public Member Functions | |
| PackedPalette (std::size_t hardware_index, std::size_t capacity=pal::max_size - 1) | |
| Constructs a PackedPalette with a given index and capacity. | |
| bool | operator== (const PackedPalette &other) const |
| std::strong_ordering | operator<=> (const PackedPalette &other) const |
| std::size_t | hardware_index () const |
| const ColorSet & | color_set () const |
| const std::vector< PackableTile::Id > & | assigned_tile_ids () const |
| std::size_t | color_count () const |
| std::size_t | color_multiplicity (std::size_t color_idx) const |
| const std::array< std::size_t, num_colors > & | color_counts () const |
| std::size_t | remaining_capacity () const |
| bool | can_fit (const ColorSet &tile_colors) const |
| Checks if a tile's colors can fit in this palette. | |
| std::size_t | union_size (const ColorSet &tile_colors) const |
| Computes the size of the union of this palette's colors with the given colors. | |
| void | add_tile (const PackableTile &tile) |
| Adds a tile to this palette. | |
| void | remove_tile (const PackableTile &tile) |
| Removes a tile from this palette and recalculates the color set. | |
| void | remove_tile (const PackableTile::Id &tile_id) |
| Removes a tile (by ID) from this palette and recalculates the color set. | |
Represents a hardware palette after packing with accumulated colors and assigned tiles.
PackedPalette tracks the colors that have been assigned to a single hardware palette during the packing process. It maintains both the accumulated color set and the list of tile IDs that have been assigned to use this palette.
GBA hardware palettes have 16 slots, but slot 0 is always transparency, leaving 15 usable color slots (the default capacity).
Definition at line 24 of file packed_palette.hpp.
|
explicit |
Constructs a PackedPalette with a given index and capacity.
| hardware_index | The hardware palette index (0-5 for primary, etc.) |
| capacity | Maximum number of colors this palette can hold (default pal::max_size - 1, i.e. 15) |
Definition at line 10 of file packed_palette.cpp.
| void porytiles::PackedPalette::add_tile | ( | const PackableTile & | tile | ) |
Adds a tile to this palette.
Adds the tile's ID to the assigned list and unions the tile's colors with this palette's color set.
| tile | The tile to add |
Definition at line 38 of file packed_palette.cpp.
|
inline |
Definition at line 54 of file packed_palette.hpp.
| bool porytiles::PackedPalette::can_fit | ( | const ColorSet & | tile_colors | ) | const |
Checks if a tile's colors can fit in this palette.
Returns true if adding the tile's colors would not exceed the palette's capacity. Takes into account colors that are already in the palette (overlap).
| tile_colors | The colors to check |
Definition at line 27 of file packed_palette.cpp.
| std::size_t porytiles::PackedPalette::color_count | ( | ) | const |
Definition at line 16 of file packed_palette.cpp.
|
inline |
Definition at line 66 of file packed_palette.hpp.
|
inline |
Definition at line 61 of file packed_palette.hpp.
|
inline |
Definition at line 49 of file packed_palette.hpp.
|
inline |
Definition at line 44 of file packed_palette.hpp.
|
inline |
Definition at line 39 of file packed_palette.hpp.
|
inline |
Definition at line 34 of file packed_palette.hpp.
| std::size_t porytiles::PackedPalette::remaining_capacity | ( | ) | const |
Definition at line 21 of file packed_palette.cpp.
| void porytiles::PackedPalette::remove_tile | ( | const PackableTile & | tile | ) |
Removes a tile from this palette and recalculates the color set.
Removes the tile's ID from the assigned list and rebuilds the color set from the remaining tiles. Colors that were unique to the removed tile will no longer be in the palette's color set.
| tile | The tile to remove |
Definition at line 48 of file packed_palette.cpp.
| void porytiles::PackedPalette::remove_tile | ( | const PackableTile::Id & | tile_id | ) |
Removes a tile (by ID) from this palette and recalculates the color set.
Removes the tile's ID from the assigned list and rebuilds the color set from the remaining tiles. Colors that were unique to the removed tile will no longer be in the palette's color set.
| tile_id | The ID of the tile to remove |
Definition at line 53 of file packed_palette.cpp.
| std::size_t porytiles::PackedPalette::union_size | ( | const ColorSet & | tile_colors | ) | const |
Computes the size of the union of this palette's colors with the given colors.
Returns the total number of unique colors that would result from adding the given colors to this palette.
| tile_colors | The colors to compute union with |
Definition at line 32 of file packed_palette.cpp.