primordial-soup/viewer/amoeba-traits.js

41 lines
4.6 KiB
JavaScript

// Small adaptations share the colony palette and leave the eyes, number badge,
// injury badge and lower-left accessibility symbol readable.
export function amoebaAdaptations(c, traits, body) {
let behind = "",
skin = "",
front = "",
mouth = "";
if (traits.has("frill"))
behind += `<path d="M24 23 13 17 16 31 3 30 11 43 1 50 15 57 9 70 26 67M75 22 87 15 85 31 98 30 91 44 100 51 87 58 94 71 77 68" fill="${c.light}" stroke="${c.stroke}" stroke-width="2.3" stroke-linejoin="round"/><path d="m14 27 11 7M10 48l12 1m-5 14 11-6m58-31-11 9m15 14-12 1m7 14-10-7" fill="none" stroke="${c.shade}" stroke-width="3" stroke-linecap="round"/>`;
if (traits.has("movement2"))
behind += `<path d="M27 65Q-2 57-5 30 9 32 14 43 1 25 7 13 28 21 33 48ZM74 61Q103 53 106 26 92 28 87 39 100 21 94 9 73 17 68 44Z" fill="${c.light}" stroke="${c.stroke}" stroke-width="2" stroke-linejoin="round"/><path d="M25 56Q14 33 10 20M22 57Q8 47 1 36M76 52Q87 29 91 16M79 53Q93 43 100 32" fill="none" stroke="${c.stroke}" stroke-width="1.6" stroke-linecap="round" opacity=".65"/>`;
if (traits.has("sensing") || traits.has("sensing2")) {
const advanced = traits.has("sensing2");
behind += `<g fill="none" stroke="${c.stroke}" stroke-width="2.6" stroke-linecap="round"><path d="M30 28Q16 13 24 5M76 28Q91 17 86 7"/>${advanced ? '<path d="M15 4q-5 7 0 13m80-12q5 7 0 13" stroke="#7698a0" stroke-width="2"/>' : ""}</g><circle cx="24" cy="6" r="4.5" fill="${c.light}" stroke="${c.stroke}" stroke-width="2"/><circle cx="86" cy="8" r="4.5" fill="${advanced ? "#f3d279" : c.light}" stroke="${c.stroke}" stroke-width="2"/>`;
}
if (traits.has("toxic"))
behind +=
'<g fill="#b99dcb" stroke="#75548b" stroke-width="1.8"><circle cx="20" cy="69" r="6"/><circle cx="80" cy="71" r="6"/><circle cx="57" cy="80" r="5"/></g>';
if (traits.has("crust"))
skin += `<path d="${body}" fill="none" stroke="#8b7052" stroke-width="5" stroke-linejoin="round"/><path d="${body}" fill="none" stroke="#e5c997" stroke-width="3" stroke-dasharray="9 4" stroke-linejoin="round"/>`;
if (traits.has("camouflage") || traits.has("camouflage2"))
skin += `<g fill="${c.stroke}" opacity=".24"><path d="M22 30q12-9 14 1t-12 9q-10-2-2-10M65 20q12-2 11 9t-12 1q-7-6 1-10M72 59q11-10 13 1t-9 11q-12-3-4-12M29 62q11-7 15 3t-11 10q-12 0-4-13"/>${traits.has("camouflage2") ? '<path d="M42 20q8-5 13 1t-5 8q-10 0-8-9M52 69q11-6 13 2t-9 7q-9-2-4-9M18 46q8-6 10 2t-5 8q-9-2-5-10"/>' : ""}</g>`;
if (traits.has("healing") || traits.has("healing2"))
front += `<g transform="rotate(-15 76 64)"><rect x="65" y="57" width="22" height="15" rx="5" fill="#fff9df" stroke="#62886f" stroke-width="1.5"/><path d="M76 60v9m-4.5-4.5h9" stroke="#529981" stroke-width="3" stroke-linecap="round"/></g>${traits.has("healing2") ? '<path d="m91 49 1.5 3.5L96 54l-3.5 1.5L91 59l-1.5-3.5L86 54l3.5-1.5Z" fill="#f3d279" stroke="#a88a40" stroke-width="1"/>' : ""}`;
if (traits.has("phd"))
front +=
'<path d="M34 15v10q17 8 34-1V14Z" fill="#456c70" stroke="#284a50" stroke-width="1.8"/><path d="m25 12 29-9 29 10-30 10Z" fill="#537e82" stroke="#284a50" stroke-width="1.8" stroke-linejoin="round"/><path d="m55 12 24 5v17m-2-3-1 7h6l-1-7" fill="#edcc78" stroke="#c09c4c" stroke-width="1.7" stroke-linecap="round"/>';
if (traits.has("suction") || traits.has("suction2"))
mouth = `<g fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M54 62q-10 18 9 17h9${traits.has("suction2") ? "m-8 0q-1 11 13 11" : ""}" stroke="${c.stroke}" stroke-width="9"/><path d="M54 62q-10 18 9 17h9${traits.has("suction2") ? "m-8 0q-1 11 13 11" : ""}" stroke="${c.light}" stroke-width="5"/></g><ellipse cx="75" cy="79" rx="4" ry="6" fill="${c.shade}" stroke="${c.stroke}" stroke-width="2"/>${traits.has("suction2") ? `<ellipse cx="80" cy="90" rx="4" ry="5" fill="${c.shade}" stroke="${c.stroke}" stroke-width="2"/>` : ""}`;
else if (traits.has("hungry"))
mouth = `<path d="M42 59q13 6 28-2-1 18-14 17-12 0-14-15Z" fill="#694c47" stroke="${c.stroke}" stroke-width="1.8"/><path d="M47 62q10 3 18-1l-1 5q-8 3-15 0Z" fill="#fff9df"/><path d="M51 71q7-6 13-1" fill="#dc9685"/>`;
if (traits.has("bite")) {
if (!mouth)
mouth = `<path d="M43 60q13 9 27-2-2 15-13 14-10 0-14-12Z" fill="#694c47" stroke="${c.stroke}" stroke-width="1.8"/>`;
const teethY = traits.has("suction") || traits.has("suction2") ? 60 : 63;
front += `<path d="m45 ${teethY} 4 9 4-7m7-1 3 8 4-11" fill="#fff9df" stroke="${c.stroke}" stroke-width="1.2" stroke-linejoin="round"/>`;
}
if (traits.has("fierce"))
front += `<path d="m32 25 16 5m13-1 17-7" fill="none" stroke="${c.stroke}" stroke-width="4" stroke-linecap="round"/>`;
return { behind, skin, front, mouth };
}