module ThemeGenerate
ThemeGenerate — procedural theme from a seed string (no AI, no shell). Public: from_seed Depends: ThemeCatalog Tests: test/lib/theme_generate_test.rb
Constants
- BOX_STYLES
- PALETTES
- WIDTHS
Public Instance Methods
Source
# File lib/theme_generate.rb, line 47 def from_seed(seed) seed_text = seed.to_s.empty? ? "default" : seed.to_s digest = Digest::SHA256.hexdigest(seed_text) bytes = digest.bytes width = WIDTHS[bytes[0] % WIDTHS.length] box = BOX_STYLES[bytes[1] % BOX_STYLES.length] palette = PALETTES[bytes[2] % PALETTES.length] slug = "gen-#{digest[0, 8]}" title_fg, title_bg = palette[:title] total_fg, total_bg = palette[:accent] card_fg = palette[:tag][0] card_bg = palette[:title][1] || palette[:title][0] tag_fg = palette[:tag][0] tag_bg = palette[:tag][1] count_fg = palette[:count][0] count_bg = palette[:count][1] { id: slug, name: generated_name(seed_text, bytes), width: width, palette: palette, frame: { header_doodle: box[:header], footer_doodle: box[:footer], separator: box[:separator] }, paint_rules: ThemeCatalog.paint_rules_for_palette(palette) } end
Source
# File lib/theme_generate.rb, line 80 def generated_name(seed_text, bytes) adjectives = %w[Crimson Azure Amber Obsidian Violet Coral Slate Indigo] nouns = %w[Frame Banner Slot Pack Margin Neon Pulse Strip Arc] adj = adjectives[bytes[3] % adjectives.length] noun = nouns[bytes[4] % nouns.length] label = seed_text.length > 20 ? seed_text[0, 20] : seed_text "#{adj} #{noun} (#{label})" end