168 lines
7.6 KiB
JavaScript
168 lines
7.6 KiB
JavaScript
import { amoeba } from "./art.js";
|
|
import { newGeneArt } from "./new-gene-art.js";
|
|
|
|
const drawCreature = (
|
|
x = 16,
|
|
y = 8,
|
|
size = 86,
|
|
variant = 0,
|
|
feature = "",
|
|
color = "green",
|
|
) =>
|
|
amoeba(color, variant, feature).replace(
|
|
"<svg viewBox=",
|
|
`<svg x="${x}" y="${y}" width="${size}" height="${size}" viewBox=`,
|
|
);
|
|
const cube = (x, y, color = "#e99b8a", size = 12) =>
|
|
`<rect x="${x}" y="${y}" width="${size}" height="${size}" rx="3" fill="${color}" stroke="#64785a" stroke-width="1.6"/><path d="m${x + 3} ${y + 3}h${size - 6}" stroke="#fff" stroke-opacity=".65" stroke-width="2" stroke-linecap="round"/>`;
|
|
const die = (x, y, dots) =>
|
|
`<g transform="translate(${x} ${y})"><rect width="23" height="23" rx="5" fill="#fffbed" stroke="#688464" stroke-width="1.8"/>${dots.map(([x, y]) => `<circle cx="${x}" cy="${y}" r="2" fill="#52734c"/>`).join("")}</g>`;
|
|
const arrows = (path, color = "#668f72") =>
|
|
`<path d="${path}" fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>`;
|
|
|
|
export function geneArt(id, colonyColor = "green") {
|
|
const creature = (x, y, size, variant, feature, color = colonyColor) =>
|
|
drawCreature(x, y, size, variant, feature, color);
|
|
let art;
|
|
switch (id) {
|
|
case "movement1":
|
|
art =
|
|
creature(16, 0, 85, 1, "movement") +
|
|
die(28, 71, [
|
|
[6, 6],
|
|
[17, 17],
|
|
]) +
|
|
die(66, 71, [
|
|
[6, 6],
|
|
[17, 6],
|
|
[6, 17],
|
|
[17, 17],
|
|
]);
|
|
break;
|
|
case "movement2":
|
|
art =
|
|
creature(16, 4, 86, 1, "movement2") +
|
|
'<circle cx="89" cy="73" r="19" fill="#fffbed" stroke="#668f72" stroke-width="2"/>' +
|
|
arrows(
|
|
"M89 59v28m-14-14h28m-18-10 4-4 4 4m6 6 4 4-4 4m-14 6 4 4 4-4m-14-14-4 4 4 4",
|
|
);
|
|
break;
|
|
case "streamline":
|
|
art =
|
|
arrows(
|
|
"M7 29c24-22 62-22 102 0M6 77c27 23 74 18 106-3M4 54h15m84-2h12",
|
|
"#71aaa1",
|
|
) +
|
|
creature(20, 7, 83, 2, "movement") +
|
|
arrows("m100 18 10 11-14 1m5 38 11 7-12 6", "#71aaa1");
|
|
break;
|
|
case "speed":
|
|
art =
|
|
arrows("M3 29h27M0 46h21M5 65h23", "#9bb28c") +
|
|
creature(26, 8, 86, 2, "movement") +
|
|
'<path d="m87 55-19 23h13l-5 20 24-27H87l6-16Z" fill="#f3d279" stroke="#a58740" stroke-width="1.6"/>';
|
|
break;
|
|
case "division":
|
|
art =
|
|
'<path d="M43 63q17-18 34-1" fill="none" stroke="#b4d16d" stroke-width="18"/>' +
|
|
creature(0, 15, 73, 1) +
|
|
creature(52, 24, 66, 2) +
|
|
arrows("M43 10h-9l-5 8m45-8h9l5 8", "#8aa16c");
|
|
break;
|
|
case "spores":
|
|
art =
|
|
creature(22, 20, 77, 0) +
|
|
creature(2, 0, 35, 1) +
|
|
creature(85, 5, 29, 2) +
|
|
creature(92, 68, 24, 0) +
|
|
'<g fill="#b8d76c" stroke="#729550" stroke-width="1"><circle cx="68" cy="9" r="4"/><circle cx="10" cy="63" r="3"/><circle cx="102" cy="46" r="4"/></g>';
|
|
break;
|
|
case "intelligence":
|
|
art =
|
|
creature(16, 14, 86, 0) +
|
|
'<g fill="none" stroke="#667757" stroke-width="2.7"><rect x="42" y="41" width="19" height="17" rx="5"/><rect x="62" y="40" width="19" height="17" rx="5"/><path d="M61 47h2m-27-2h6m39-1h5"/></g><path d="M72 13c0-13 19-13 19 0 0 6-5 6-5 12h-9c0-6-5-6-5-12Z" fill="#ffe89b" stroke="#ad9b4d" stroke-width="1.7"/><path d="M78 29h7m-16-21-4-2m28 2 4-2m-16-8v-4" stroke="#ad9b4d" stroke-width="2" stroke-linecap="round"/>';
|
|
break;
|
|
case "defense":
|
|
art =
|
|
creature(15, 8, 85, 2) +
|
|
'<circle cx="86" cy="69" r="25" fill="#c69567" stroke="#876447" stroke-width="3"/><path d="M74 49v40m12-44v47m12-42v38" stroke="#aa7b52" stroke-width="2"/><circle cx="86" cy="69" r="9" fill="#e9dfba" stroke="#887e61" stroke-width="2"/>';
|
|
break;
|
|
case "armor":
|
|
art =
|
|
creature(14, 9, 89, 2, "shield") +
|
|
'<path d="M34 38C32 0 83 0 87 36l-20-5-4 8-7-8Z" fill="#c9d5cc" stroke="#647d71" stroke-width="2"/><path d="M60 11v19m-19-3 10-9" stroke="#f6fcf5" stroke-width="4" stroke-linecap="round"/>';
|
|
break;
|
|
case "escape":
|
|
art =
|
|
arrows("M5 76q-5-35 25-45m-10-3 11 2-3 12", "#a0b496") +
|
|
creature(30, 2, 78, 1, "movement") +
|
|
arrows("M44 83q38 17 64-12m-3 13 4-14-15 1", "#8bab91");
|
|
break;
|
|
case "substitution":
|
|
art =
|
|
creature(21, 0, 76, 2) +
|
|
cube(11, 76) +
|
|
cube(65, 74, "#8eb8d5") +
|
|
cube(85, 74, "#8eb8d5") +
|
|
arrows("M33 80h22m-5-5 5 5-5 5M57 92H34m5-4-5 4 5 4");
|
|
break;
|
|
case "ray":
|
|
art =
|
|
'<circle cx="16" cy="17" r="9" fill="#f3d279"/><path d="M16 2V0M1 17h-4m7-12-4-4m24 4 4-4m-3 26 4 4" stroke="#d5b557" stroke-width="2"/>' +
|
|
creature(24, 20, 76, 0) +
|
|
'<path d="M26 33Q58-15 94 30l-17-2-9 8-14-6-11 8Z" fill="#a2c7b5" stroke="#5d8f7b" stroke-width="2"/><path d="M59 17q-3 58 6 51m-6-51L43 38m16-21 18 11" fill="none" stroke="#5d8f7b" stroke-width="2"/>';
|
|
break;
|
|
case "tentacle":
|
|
art =
|
|
'<path d="M38 65C4 71-4 27 15 28s11 18 3 13M83 64c31 15 41-14 29-23-11-6-13 9-5 8" fill="none" stroke="#85ad57" stroke-width="9" stroke-linecap="round"/>' +
|
|
creature(19, 7, 84, 1) +
|
|
cube(8, 20, "#8eb8d5") +
|
|
cube(96, 35, "#eed17c");
|
|
break;
|
|
case "holding":
|
|
art =
|
|
creature(0, 10, 79, 0) +
|
|
creature(60, 24, 54, 1, "", colonyColor === "blue" ? "red" : "blue") +
|
|
'<g fill="none" stroke="#708d78" stroke-width="4"><rect x="49" y="71" width="19" height="12" rx="6" transform="rotate(-24 49 71)"/><rect x="61" y="69" width="19" height="12" rx="6" transform="rotate(-24 61 69)"/></g>';
|
|
break;
|
|
case "longevity":
|
|
art =
|
|
creature(14, 8, 87, 0) +
|
|
'<rect x="31" y="64" width="26" height="12" rx="4" fill="#f3dca7" stroke="#b69f6f" stroke-width="1.4" transform="rotate(25 44 70)"/><path d="M44 67v6m-3-3h6" stroke="#bc9471"/><path d="M92 38s-20-12-16-24c3-7 13-6 16 1 4-7 15-7 16 1 2 10-16 22-16 22Z" fill="#e49c8c" stroke="#a56860" stroke-width="2"/>';
|
|
break;
|
|
case "frugality":
|
|
art =
|
|
creature(16, 4, 86, 1, "food") +
|
|
'<ellipse cx="42" cy="83" rx="25" ry="9" fill="#fff8e6" stroke="#b9b68c" stroke-width="2"/>' +
|
|
cube(35, 69, "#8eb8d5");
|
|
break;
|
|
case "struggle":
|
|
art =
|
|
creature(16, 6, 87, 2, "bite") +
|
|
'<g fill="none" stroke="#899d8f" stroke-width="3" stroke-linecap="round"><path d="M15 50v40M8 38v12q7 8 14 0V38m-7 0v13M102 37v53m0-53q-15 12 0 24"/></g>';
|
|
break;
|
|
case "parasitism":
|
|
art =
|
|
creature(0, 17, 75, 0) +
|
|
creature(64, 29, 50, 1, "", colonyColor === "red" ? "blue" : "red") +
|
|
'<path d="m46 64 11 8h20V49" fill="none" stroke="#b89862" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="87" cy="25" r="12" fill="#efdb89" stroke="#ac9954" stroke-width="2"/><path d="M85 18h4m-3 0v6l-4 6h10l-4-6v-6" fill="none" stroke="#978847" stroke-width="1.6"/>';
|
|
break;
|
|
case "persistence":
|
|
art =
|
|
arrows(
|
|
"M15 60C-5 6 78-9 105 29m-2-14 3 15-15 1M105 44c24 51-51 67-79 37m0 13V80h14",
|
|
"#86a26b",
|
|
) + creature(24, 17, 72, 1);
|
|
break;
|
|
case "aggression":
|
|
art =
|
|
creature(16, 4, 86, 0, ["spines", "bite", "fierce"]) +
|
|
'<path d="M24 48C4 38 0 59 8 68l15 2 8-11Z" fill="#de9380" stroke="#ab6f5c" stroke-width="2"/><path d="M94 47c20-10 24 11 16 20l-15 2-8-11Z" fill="#de9380" stroke="#ab6f5c" stroke-width="2"/><path d="m11 68 12 2m74-1 10-2" stroke="#f2c7a5" stroke-width="6"/>';
|
|
break;
|
|
default:
|
|
art =
|
|
newGeneArt(id, { creature, cube, die, arrows }, colonyColor) ??
|
|
creature();
|
|
}
|
|
return `<svg class="gene-illustration" viewBox="-6 -6 132 112" aria-hidden="true">${art}</svg>`;
|
|
}
|