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 < pal.
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);
69 return print_palette_with_highlights_impl(pal, {}, format_);
74 return print_palette_with_highlights_impl(pal, {}, format_);
78 const Palette<Rgba32> &pal,
const std::vector<std::size_t> &slots)
const
80 return print_palette_with_highlights_impl(pal, slots, format_);
86 return print_palette_with_highlights_impl(pal, slots, format_);
90 const PaletteHint &hint,
const std::vector<std::size_t> &slots)
const
92 std::vector<std::string> lines{};
95 lines.push_back(format_->
format(
"name: \"{}\"",
FormatParam{hint.name(), Style::bold}));
96 lines.emplace_back(
"colors:");
98 for (std::size_t i = 0; i < hint.
pal().size(); ++i) {
99 const bool is_highlighted = std::ranges::find(slots, i) != slots.end();
102 if (is_highlighted) {
109 std::string slot_str;
110 if (hint.
pal().is_wildcard(i)) {
111 panic(
"illegal wildcard in pal hint '" + hint.
name() +
"' at index '" + std::to_string(i) +
"'");
116 if (is_highlighted) {
117 const std::string color_text =
122 const std::string color_text = format_->
style(color.
to_csv_str(), color_style);
126 lines.push_back(slot_str);
136 std::vector<std::size_t> highlight_slots;
138 for (
const auto &[index, color] : index_to_color) {
139 if (covered_colors.contains(color)) {
140 highlight_slots.push_back(index);
145 std::vector<std::string> lines = print_palette_with_highlights_impl(pal, highlight_slots, format_);
148 if (!missing_colors.empty()) {
149 lines.push_back(format_->
format(
"{}",
FormatParam{
"------ Palette Still Missing ------", Style::bold}));
150 for (
const auto &color : missing_colors) {
152 const std::string color_text = format_->
style(color.
to_jasc_str(), color_style);
160std::vector<std::string>
163 std::vector<std::string> lines{};
164 for (
const auto &[color, count] : colors_counts) {
166 const std::string color_text = format_->
style(color.
to_jasc_str(), color_style);
std::vector< std::string > print_rgba_pal(const Palette< Rgba32, pal::max_size > &pal) const override
std::vector< std::string > print_rgba_pal_with_highlights(const Palette< Rgba32 > &pal, const std::vector< std::size_t > &slots) const override
std::vector< std::string > print_rgba_palette_covered_missing(const Palette< Rgba32, pal::max_size > &pal, 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_pal_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 > & pal() 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.