module RabbotMetaColorsThemes
Constants
- IRC_TAG
- MAX_THEME_LIST_LINES
- PALETTE_SLOTS
- SPECTRUM_BANDS
- STYLE_TITLE
- SWATCHES_PER_LINE
Public Instance Methods
Source
# File lib/rabbot_meta_colors_themes.rb, line 75 def format_spectrum body = SPECTRUM_BANDS.map do |group, from, to| codes = (from..to).to_a swatches = codes.map { |code| "#{IrcExtendedColors.swatch(code)}#{code}" }.join(" ") label = IrcExtendedColors.group_label(group) "#{label} #{from}–#{to}: #{swatches}" end IrcReply.card( tag: IRC_TAG, title: "Spectrum 49–98", body_lines: body, footer_parts: ["#{IrcExtendedColors.spectrum_codes.length} colours", "purple shades → greyscale"], heading_style: STYLE_TITLE ) end
Source
# File lib/rabbot_meta_colors_themes.rb, line 53 def format_theme_palette(theme_id, catalog: ThemeCatalog) theme = catalog.get(theme_id) return nil unless theme palette = theme[:palette] || {} body = PALETTE_SLOTS.filter_map do |slot| pair = palette[slot] next unless pair palette_row(slot.to_s, Array(pair)) end extended = theme_uses_extended?(palette) ? "extended" : "classic" IrcReply.card( tag: IRC_TAG, title: "Theme — #{theme[:name]}", body_lines: body, footer_parts: [extended, "!theme use #{theme[:id]}"], heading_style: STYLE_TITLE ) end
Source
# File lib/rabbot_meta_colors_themes.rb, line 30 def format_themes_list(catalog: ThemeCatalog) rows = catalog.all.map do |theme| extended = theme_uses_extended?(theme[:palette]) ? "extended" : "classic" { label: theme[:id], value: "#{theme[:name]} (#{extended})" } end body = TextAlign.format_colon_rows(rows).take(MAX_THEME_LIST_LINES) total = catalog.all.length IrcReply.card( tag: IRC_TAG, title: "Built-in theme palettes", body_lines: [ *body, "Apply with !theme use <id> — paint rules use palette slots below." ], footer_parts: ["#{total} themes", "!rabbot colors neon"], heading_style: STYLE_TITLE ) end
Source
# File lib/rabbot_meta_colors_themes.rb, line 105 def pair_slot_marker(fg, bg) fg_i = fg.to_i if bg.nil? return IrcExtendedColors.extended?(fg_i) ? "(fixed)" : "(classic)" end bg_i = bg.to_i if IrcExtendedColors.extended?(fg_i) && IrcExtendedColors.extended?(bg_i) "(fixed)" elsif !IrcExtendedColors.extended?(fg_i) && !IrcExtendedColors.extended?(bg_i) "(classic)" else "(mixed)" end end
Source
# File lib/rabbot_meta_colors_themes.rb, line 92 def palette_row(label, pair) fg = pair[0] bg = pair[1] marker = pair_slot_marker(fg, bg) if bg swatch = IrcExtendedColors.swatch(fg, bg: bg) "#{label}: #{swatch} #{fg},#{bg} #{marker}" else swatch = IrcExtendedColors.swatch(fg) "#{label}: #{swatch} #{fg} #{marker}" end end
Source
# File lib/rabbot_meta_colors_themes.rb, line 121 def theme_uses_extended?(palette) Array(palette&.values).flatten.any? { |code| code.to_i >= IrcExtendedColors::EXTENDED_MIN } end