79 lines
4.8 KiB
JavaScript
79 lines
4.8 KiB
JavaScript
const colors = {
|
|
green: {
|
|
body: "#b7d967",
|
|
shade: "#8cb74a",
|
|
light: "#e5ef9e",
|
|
stroke: "#52753c",
|
|
cheek: "#96bc50",
|
|
},
|
|
red: {
|
|
body: "#e99b8a",
|
|
shade: "#ce7969",
|
|
light: "#ffcab2",
|
|
stroke: "#a06151",
|
|
cheek: "#d6776e",
|
|
},
|
|
blue: {
|
|
body: "#8eb8d5",
|
|
shade: "#6398bc",
|
|
light: "#c5e0e7",
|
|
stroke: "#4a7c96",
|
|
cheek: "#7ca8c9",
|
|
},
|
|
yellow: {
|
|
body: "#eed17c",
|
|
shade: "#d4b14e",
|
|
light: "#fff0b4",
|
|
stroke: "#aa8c45",
|
|
cheek: "#dfb965",
|
|
},
|
|
};
|
|
const iconPaths = {
|
|
help: '<circle cx="12" cy="12" r="9"/><path d="M9.5 9a2.5 2.5 0 0 1 5 0c0 2-2.5 2-2.5 4m0 3v.1"/>',
|
|
heart:
|
|
'<path d="M12 20S3 15 3 8.5A4.5 4.5 0 0 1 12 7a4.5 4.5 0 0 1 9 1.5C21 15 12 20 12 20Z"/>',
|
|
bio: '<path d="M9 2h6m-5 0v7L5 18q-1 3 3 3h8q4 0 3-3l-5-9V2M8 14h8"/><circle cx="11" cy="17" r="1"/>',
|
|
grid: '<rect x="3" y="3" width="18" height="18" rx="3"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/>',
|
|
expand: '<path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5"/>',
|
|
"sound-off": '<path d="M11 4 6 8H3v8h3l5 4Zm5 5 6 6m-6 0 6-6"/>',
|
|
sound: '<path d="M11 4 6 8H3v8h3l5 4Zm4 4q4 4 0 8m3-11q7 7 0 14"/>',
|
|
history: '<path d="M3 10a9 9 0 1 1 1 7M3 4v6h6m3-4v6l4 2"/>',
|
|
spark: '<path d="m12 2 3 7 7 3-7 3-3 7-3-7-7-3 7-3Z"/>',
|
|
wave: '<path d="M2 8q3-5 7 0t7 0 6 0M2 15q3-5 7 0t7 0 6 0"/>',
|
|
arrow: '<path d="M4 12h16m-6-6 6 6-6 6"/>',
|
|
sun: '<circle cx="12" cy="12" r="4"/><path d="M12 1v2m0 18v2M1 12h2m18 0h2M4 4l2 2m12 12 2 2M4 20l2-2M18 6l2-2"/>',
|
|
divide:
|
|
'<path d="M11 5C4-2-3 14 5 19c4 3 5-3 7-3s3 6 7 3c8-5 1-21-6-14Z"/><circle cx="7" cy="11" r="2"/><circle cx="17" cy="11" r="2"/>',
|
|
shield:
|
|
'<path d="m12 2 9 4v7q-2 6-9 9-7-3-9-9V6Z"/><path d="m8 12 3 3 5-6"/>',
|
|
undo: '<path d="M4 11a8 8 0 1 1 2 9M4 4v7h7"/>',
|
|
};
|
|
const icon = (name) =>
|
|
`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${iconPaths[name] || iconPaths.spark}</svg>`;
|
|
|
|
let artId = 0;
|
|
function amoeba(color, variant = 0, feature = "") {
|
|
const c = colors[color];
|
|
const id = `amoeba-${++artId}`;
|
|
const body =
|
|
variant % 3 === 0
|
|
? "M23 57C9 57 7 43 18 39C8 25 20 16 31 24C35 9 48 9 53 20C64 7 79 16 75 30C95 27 97 43 84 49C100 59 91 73 76 69C72 88 54 83 48 76C37 89 22 79 24 69C9 75 5 62 23 57Z"
|
|
: variant % 3 === 1
|
|
? "M18 47C5 34 16 22 29 27C24 10 42 6 49 20C56 5 73 14 70 25C88 16 98 30 84 40C103 49 94 63 81 63C90 80 72 87 61 73C58 90 38 89 34 73C19 84 7 74 18 61C5 63 5 48 18 47Z"
|
|
: "M19 55C5 48 11 30 25 33C12 17 34 8 40 24C44 5 64 8 66 25C81 11 97 30 83 42C104 43 98 63 82 62C89 80 65 89 59 74C47 93 27 86 31 70C11 82 4 61 19 55Z";
|
|
return `<svg viewBox="0 0 100 100" aria-hidden="true"><defs><radialGradient id="${id}" cx="40%" cy="24%" r="75%"><stop stop-color="${c.light}"/><stop offset=".48" stop-color="${c.body}"/><stop offset="1" stop-color="${c.shade}"/></radialGradient></defs>
|
|
${feature === "movement" ? `<path d="M23 65Q-12 45 2 35Q17 40 23 53M77 60Q105 35 99 25Q84 31 77 43" fill="${c.body}" stroke="${c.stroke}" stroke-width="2"/>` : ""}
|
|
${feature === "spines" ? `<path d="M25 29 17 8 39 23M64 21 80 6 77 31M82 54 99 71 76 69M37 72 31 94 52 76M19 52 0 64 23 67" fill="${c.shade}" stroke="${c.stroke}" stroke-width="2" stroke-linejoin="round"/>` : ""}
|
|
<path d="${body}" fill="url(#${id})" stroke="${c.stroke}" stroke-width="2" stroke-linejoin="round"/>
|
|
<path d="M26 32q1-6 7-7M55 24q5-3 9 0" stroke="#fff" stroke-opacity=".65" stroke-width="4" fill="none" stroke-linecap="round"/>
|
|
<ellipse cx="36" cy="64" rx="7" ry="5" fill="${c.cheek}" opacity=".6"/><ellipse cx="71" cy="60" rx="6" ry="4" fill="${c.cheek}" opacity=".55"/>
|
|
<circle cx="29" cy="46" r="3" fill="${c.light}"/><circle cx="74" cy="38" r="2" fill="${c.shade}" opacity=".45"/><circle cx="47" cy="70" r="2" fill="${c.shade}" opacity=".7"/>
|
|
<g class="eyes"><ellipse cx="43" cy="41" rx="12" ry="14" fill="#fffef1" stroke="${c.stroke}" stroke-width="1.7"/><ellipse cx="65" cy="40" rx="12" ry="14.5" fill="#fffef1" stroke="${c.stroke}" stroke-width="1.7"/>
|
|
<ellipse cx="${45 + (variant % 2)}" cy="44" rx="4.3" ry="6.2" fill="#24433a"/><ellipse cx="${65 + (variant % 2)}" cy="43" rx="4.3" ry="6.2" fill="#24433a"/><circle cx="44" cy="41" r="1.8" fill="white"/><circle cx="64" cy="40" r="1.8" fill="white"/></g>
|
|
<path d="M47 61q7 8 14-1" stroke="${c.stroke}" stroke-width="2" stroke-linecap="round" fill="none"/>
|
|
${feature === "food" ? '<path d="M65 70q9-13 11-2q-1 12-11 2" fill="#ffd4a2" stroke="#86613c" stroke-width="1.5"/><rect x="68" y="68" width="9" height="8" rx="2" fill="#ed9785" stroke="#a46c54"/>' : ""}
|
|
${feature === "shield" ? '<path d="m75 55 18 7v12q-5 10-18 15-12-5-15-15V62Z" fill="#dbe8e0" stroke="#4d7767" stroke-width="2"/><path d="m68 71 5 5 11-11" fill="none" stroke="#6b995b" stroke-width="3"/>' : ""}
|
|
</svg>`;
|
|
}
|
|
|
|
export { colors, icon, amoeba };
|