// scripts/generate-diverse-avatars.mjs // 创建一个真正多样化的头像库 // 不绑定具体 Bot,生成200个完全不同风格的头像 // Bot 从这个库中随机匹配 import { writeFileSync, existsSync, mkdirSync } from "fs"; import { resolve, dirname } from "path"; import { fileURLToPath } from "url"; const __dirname = dirname(fileURLToPath(import.meta.url)); const AVATAR_DIR = resolve(__dirname, "..", "public", "bot-avatars"); const MANIFEST_PATH = resolve(AVATAR_DIR, "manifest.json"); if (!existsSync(AVATAR_DIR)) mkdirSync(AVATAR_DIR, { recursive: true }); // ---------- 调色板 ---------- const PALETTES = [ ["#FF6B6B", "#FF8E8E"], ["#FF9F43", "#FFB366"], ["#FECA57", "#FFD571"], ["#48DBFB", "#6BE2FC"], ["#1DD1A1", "#45D9B3"], ["#A29BFE", "#BEB8FF"], ["#FD79A8", "#FD8FB8"], ["#00CEC9", "#33D9D5"], ["#E17055", "#E58874"], ["#6C5CE7", "#8378EC"], ["#FDCB6E", "#FED88C"], ["#E84393", "#EB6CA8"], ["#00B894", "#33C8A7"], ["#0984E3", "#339DEB"], ["#D63031", "#DE5252"], ["#55EFC4", "#77F2D3"], ["#74B9FF", "#8DC8FF"], ["#FF7675", "#FF8D8D"], ["#81ECEC", "#9BF0F0"], ["#A8E6CF", "#BCEDD7"], ["#FFD3B6", "#FFDFCD"], ["#D4A5A5", "#DFB9B9"], ["#C8D6E5", "#D5E0ED"], ["#F8B500", "#F9C533"], ["#0052CC", "#336FD6"], ["#36B37E", "#55C192"], ["#FF5630", "#FF7354"], ["#6554C0", "#7D6FCC"], ["#FFB400", "#FFC233"], ["#009DAE", "#00B3C6"], ]; // 头像尺寸 const W = 512, H = 512, CX = 256, CY = 256; // ---------- 图标库(共66个不同图标)---------- // 每个图标是一个返回 SVG path/元素的函数 const ICONS = []; // === 动物 === ICONS.push(() => { // 猫 return ` `; }); ICONS.push(() => { // 狗 return ` `; }); ICONS.push(() => { // 鱼 return ` `; }); ICONS.push(() => { // 鸟 return ` `; }); ICONS.push(() => { // 兔子 return ` `; }); ICONS.push(() => { // 狐狸 return ` `; }); ICONS.push(() => { // 熊猫 return ` `; }); ICONS.push(() => { // 大象 return ` `; }); ICONS.push(() => { // 猫头鹰 return ` `; }); // === 自然 === ICONS.push(() => { // 山 return ` `; }); ICONS.push(() => { // 太阳 return ` ${Array.from({length:12}, (_,i) => { const a = i * 30 * Math.PI/180; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 月亮 return ` ${Array.from({length:5}, (_,i) => { const a = i * 60 * Math.PI/180; const cx2 = Math.cos(a)*35, cy2 = Math.sin(a)*35; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 星 return ` `; }); ICONS.push(() => { // 树 return ` `; }); ICONS.push(() => { // 花 return ` ${Array.from({length:6}, (_,i) => { const a = i * 60 * Math.PI/180; const cx2 = Math.cos(a)*50, cy2 = Math.sin(a)*50; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 叶子 return ` ${Array.from({length:7}, (_,i) => { const y = -60 + i*20; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 云 return ` `; }); ICONS.push(() => { // 闪电 return ` `; }); ICONS.push(() => { // 雨滴 return ` `; }); ICONS.push(() => { // 火焰 return ` `; }); // === 科技 === ICONS.push(() => { // 齿轮 return ` ${Array.from({length:8}, (_,i) => { const a = i * 45 * Math.PI/180; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 机器人 return ` `; }); ICONS.push(() => { // 灯泡 return ` ${Array.from({length:4}, (_,i) => { const a = (i*30-45) * Math.PI/180; return ``; }).join("\n ")} `; }); ICONS.push(() => { // 代码符号 return ` `; }); ICONS.push(() => { // WiFi return ` `; }); ICONS.push(() => { // 芯片 return ` ${Array.from({length:8}, (_,i) => { const pos = -56 + i * 16; return ` `; }).join("\n ")} `; }); ICONS.push(() => { // 火箭 return ` `; }); ICONS.push(() => { // 盾牌 return ` `; }); // === 商业/学习 === ICONS.push(() => { // 图表(柱状图) return ` `; }); ICONS.push(() => { // 钱包/钱袋 return ` `; }); ICONS.push(() => { // 书本 return `