16template <std::
size_t N>
17std::vector<std::string> print_palette_with_highlights_impl(
20 std::vector<std::string> lines{};
23 lines.emplace_back(
" JASC-PAL");
24 lines.emplace_back(
" 0100");
27 for (std::size_t i = 0; i < palette.
size(); ++i) {
28 const bool is_highlighted = std::ranges::find(highlight_slots, i) != highlight_slots.end();
47 const std::string color_text =
52 const std::string color_text = format->
style(color.
to_jasc_str(), color_style);
57 lines.push_back(slot_str);
67std::vector<std::string>
70 return print_palette_with_highlights_impl(palette, {}, format_);
75 return print_palette_with_highlights_impl(palette, {}, format_);
79 const Palette<Rgba32> &palette,
const std::vector<std::size_t> &slots)
const
81 return print_palette_with_highlights_impl(palette, slots, format_);
87 return print_palette_with_highlights_impl(palette, slots, format_);
91 const PaletteHint &hint,
const std::vector<std::size_t> &slots)
const
93 std::vector<std::string> lines{};
96 lines.push_back(format_->
format(
"name: \"{}\"",
FormatParam{hint.name(), Style::bold}));
97 lines.emplace_back(
"colors:");
99 for (std::size_t i = 0; i < hint.
palette().size(); ++i) {
100 const bool is_highlighted = std::ranges::find(slots, i) != slots.end();
103 if (is_highlighted) {
110 std::string slot_str;
111 if (hint.
palette().is_wildcard(i)) {
112 panic(
"illegal wildcard in palette hint '" + hint.
name() +
"' at index '" + std::to_string(i) +
"'");
117 if (is_highlighted) {
118 const std::string color_text =
123 const std::string color_text = format_->
style(color.
to_csv_str(), color_style);
127 lines.push_back(slot_str);
135 std::set<Rgba32> covered_colors,
136 std::set<Rgba32> missing_colors)
const
139 std::vector<std::size_t> highlight_slots;
141 for (
const auto &[index, color] : index_to_color) {
142 if (covered_colors.contains(color)) {
143 highlight_slots.push_back(index);
148 std::vector<std::string> lines = print_palette_with_highlights_impl(palette, highlight_slots, format_);
151 if (!missing_colors.empty()) {
152 lines.push_back(format_->
format(
"{}",
FormatParam{
"------ Palette Still Missing ------", Style::bold}));
153 for (
const auto &color : missing_colors) {
155 const std::string color_text = format_->
style(color.
to_jasc_str(), color_style);
163std::vector<std::string>
166 std::vector<std::string> lines{};
167 for (
const auto &[color, count] : colors_counts) {
169 const std::string color_text = format_->
style(color.
to_jasc_str(), color_style);
std::vector< std::string > print_rgba_palette_covered_missing(const Palette< Rgba32, palette::max_size > &palette, std::set< Rgba32 > covered_colors, std::set< Rgba32 > missing_colors) const override
std::vector< std::string > print_rgba_counts(const std::vector< std::pair< Rgba32, unsigned int > > &colors_counts) const override
std::vector< std::string > print_rgba_palette_with_highlights(const Palette< Rgba32 > &palette, const std::vector< std::size_t > &slots) const override
std::vector< std::string > print_rgba_palette(const Palette< Rgba32, palette::max_size > &palette) const override
std::vector< std::string > print_palette_hint_with_highlights(const PaletteHint &hint, const std::vector< std::size_t > &slots) const override
Represents a palette hint for the palette packing algorithm.
const std::string & name() const
const Palette< Rgba32 > & palette() const
A generic palette container for colors that support transparency checking.
std::map< PaletteIndex, ColorType > index_to_color_map() const
Creates a map from palette indices to their colors.
std::size_t size() const
Returns the number of slots in the palette.
ColorType at(std::size_t index) const
Gets the color at a specific index.
bool is_wildcard(std::size_t index) const
Checks if a slot is a wildcard.
Represents a 32-bit RGBA color.
std::string to_csv_str() const
std::uint8_t blue() const
std::string to_jasc_str() const
std::uint8_t green() const
Text styling class supporting formatting, foreground colors, and background colors.
static const Style italic
Italic text formatting.
static const Style yellow
Yellow foreground color.
static const Style bold
Bold text formatting.
Abstract base class for applying text styling with context-aware formatting.
virtual std::string style(const std::string &text, Style styles) const =0
Applies styling to a text string.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > ¶ms) const
Formats a string with styled parameters using fmtlib syntax.
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
constexpr Style rgb_fg_style(std::uint8_t r, std::uint8_t g, std::uint8_t b)
Creates a Style value with a custom RGB foreground color.