Porytiles
Loading...
Searching...
No Matches
prefilled_palette.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <compare>
4#include <cstddef>
5
8
9namespace porytiles {
10
26 public:
40 [[nodiscard]] static PrefilledPalette
41 fully_locked(std::size_t hardware_index, ColorSet color_set, std::size_t occupied_slots);
42
58 [[nodiscard]] static PrefilledPalette partially_locked(
59 std::size_t hardware_index,
61 std::size_t occupied_slots,
62 std::size_t total_capacity = pal::max_size - 1);
63
64 [[nodiscard]] bool operator==(const PrefilledPalette &other) const
65 {
66 return hardware_index_ == other.hardware_index_;
67 }
68
69 [[nodiscard]] std::strong_ordering operator<=>(const PrefilledPalette &other) const
70 {
71 return hardware_index_ <=> other.hardware_index_;
72 }
73
74 [[nodiscard]] std::size_t hardware_index() const
75 {
76 return hardware_index_;
77 }
78
79 [[nodiscard]] const ColorSet &fixed_colors() const
80 {
81 return fixed_colors_;
82 }
83
84 [[nodiscard]] std::size_t fixed_color_count() const;
85
86 [[nodiscard]] std::size_t occupied_slots() const
87 {
88 return occupied_slots_;
89 }
90
91 [[nodiscard]] std::size_t available_capacity() const
92 {
93 return available_capacity_;
94 }
95
96 [[nodiscard]] bool is_fully_locked() const
97 {
98 return available_capacity_ == 0;
99 }
100
112 [[nodiscard]] bool can_accommodate(const ColorSet &tile_colors) const;
113
114 private:
116 std::size_t hardware_index, ColorSet fixed_colors, std::size_t available_capacity, std::size_t occupied_slots);
117
118 std::size_t hardware_index_;
119 ColorSet fixed_colors_;
120 std::size_t available_capacity_;
121 std::size_t occupied_slots_;
122};
123
124} // namespace porytiles
A set of colors represented as a bitset.
Definition color_set.hpp:26
Pre-assigned palette with wildcard support for palette packing.
std::size_t fixed_color_count() const
static PrefilledPalette fully_locked(std::size_t hardware_index, ColorSet color_set, std::size_t occupied_slots)
Creates a fully locked PrefilledPalette.
std::strong_ordering operator<=>(const PrefilledPalette &other) const
std::size_t hardware_index() const
std::size_t available_capacity() const
bool can_accommodate(const ColorSet &tile_colors) const
Checks if a tile's colors can be accommodated by this palette.
std::size_t occupied_slots() const
bool operator==(const PrefilledPalette &other) const
static PrefilledPalette partially_locked(std::size_t hardware_index, ColorSet fixed_colors, std::size_t occupied_slots, std::size_t total_capacity=pal::max_size - 1)
Creates a partially locked palette with available capacity.
const ColorSet & fixed_colors() const
constexpr std::size_t max_size
Definition palette.hpp:19