Rename proto-palettes to color sets (copied from rsgbds)

This commit is contained in:
Rangi42
2025-07-23 21:03:50 -04:00
parent 18e35053fa
commit 1849a35e61
7 changed files with 218 additions and 228 deletions

38
include/gfx/color_set.hpp Normal file
View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
#ifndef RGBDS_GFX_COLOR_SET_HPP
#define RGBDS_GFX_COLOR_SET_HPP
#include <array>
#include <stddef.h>
#include <stdint.h>
class ColorSet {
public:
static constexpr size_t capacity = 4;
private:
// Up to 4 colors, sorted, and where SIZE_MAX means the slot is empty
// (OK because it's not a valid color index)
// Sorting is done on the raw numerical values to lessen `compare`'s complexity
std::array<uint16_t, capacity> _colorIndices{UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX};
public:
// Adds the specified color to the set, or **silently drops it** if the set is full.
void add(uint16_t color);
enum ComparisonResult {
NEITHER,
WE_BIGGER,
THEY_BIGGER = -1,
};
ComparisonResult compare(ColorSet const &other) const;
size_t size() const;
bool empty() const;
decltype(_colorIndices)::const_iterator begin() const;
decltype(_colorIndices)::const_iterator end() const;
};
#endif // RGBDS_GFX_COLOR_SET_HPP