primordial-soup/viewer/new-gene-art.js

250 lines
12 KiB
JavaScript

import { colors } from "./art.js";
const sparkle = (x, y, size = 7) =>
`<path d="M${x} ${y - size}q1 ${size - 1} ${size} ${size}q-${size - 1} 1-${size} ${size}q-1-${size - 1}-${size}-${size}q${size - 1}-1 ${size}-${size}Z" fill="#fff8cd" stroke="#a0ad76" stroke-width="1.5"/>`;
const flask = (x, y, size = 23, fill = "#a9ca80") =>
`<svg x="${x}" y="${y}" width="${size}" height="${size}" viewBox="0 0 28 30" overflow="visible"><path d="M10 2h8m-6 0v10L5 24q-2 4 3 4h12q5 0 3-4l-7-12V2" fill="#fff9de" stroke="#6d8055" stroke-width="1.8" stroke-linejoin="round"/><path d="m9 19-3 6q0 1 3 1h10q3 0 3-1l-3-6Z" fill="${fill}"/><circle cx="12" cy="21" r="1.5" fill="#fffce8"/></svg>`;
const patch = (x, y, angle = -20) =>
`<g transform="translate(${x} ${y}) rotate(${angle} 13 6)"><rect width="26" height="13" rx="4" fill="#f1d2a0" stroke="#a58160" stroke-width="1.5"/><rect x="9" y="2" width="8" height="9" rx="2" fill="#fff8dd"/><path d="M4 4v1m1 3v1m17-5v1m-1 3v1" stroke="#b18f69" stroke-width="1.5" stroke-linecap="round"/></g>`;
const leaf = (x, y, size = 25, angle = 0, color = "#a4c180") =>
`<g transform="translate(${x} ${y}) rotate(${angle}) scale(${size / 25})"><path d="M0 22Q-6 1 22 0Q24 23 0 22Z" fill="${color}" stroke="#688360" stroke-width="1.7"/><path d="M-4 26 16 6m-11 11-1-8m1 8 9 0" stroke="#688360" stroke-width="1.4" fill="none" stroke-linecap="round"/></g>`;
const tile = (x, y, width = 31, height = 30) =>
`<rect x="${x}" y="${y}" width="${width}" height="${height}" rx="6" fill="#cce3d4" stroke="#91b2a0" stroke-width="1.6" stroke-dasharray="4 3"/>`;
const forecast = (x, y, angle = 0, advanced = false) =>
`<g transform="translate(${x} ${y}) rotate(${angle} 18 23)"><rect width="36" height="47" rx="6" fill="#fff8df" stroke="#9aaa7a" stroke-width="1.8"/><path d="M1 15h34" stroke="#d5dfb8"/><circle cx="12" cy="9" r="4" fill="#f1cf72"/><path d="m19 9h9" stroke="#a1bea4" stroke-width="2"/><path d="M8 33h20m-7-7 7 7-7 7" fill="none" stroke="#669b8c" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>${advanced ? '<path d="m28 3 1.2 3.8L33 8l-3.8 1.2L28 13l-1.2-3.8L23 8l3.8-1.2Z" fill="#d7ae57"/>' : ""}</g>`;
const geneCard = (x, y, color, angle = 0) =>
`<g transform="translate(${x} ${y}) rotate(${angle} 16 21)"><rect width="32" height="43" rx="5" fill="${color}" stroke="#748769" stroke-width="1.8"/><path d="M11 8c0 10 10 15 10 27M21 8c0 10-10 15-10 27m1-24h8m-6 8h4m-4 8h4m-6 6h8" fill="none" stroke="#617c58" stroke-width="1.8" stroke-linecap="round"/></g>`;
export function newGeneArt(id, { creature, cube, die, arrows }, colonyColor) {
const c = colors[colonyColor];
const other = colonyColor === "blue" ? "red" : "blue";
const food = ["red", "blue", "yellow", "green"]
.filter((color) => color !== colonyColor)
.map((color) => colors[color].body);
switch (id) {
case "doris-frank":
return (
creature(0, 5, 65, 0, "glasses") +
creature(56, 8, 63, 1, "", other) +
'<path d="m19 65 68-2 18 28H6Z" fill="#d9bd8d" stroke="#967e59" stroke-width="2"/><path d="m25 70 56-1 9 17H17Z" fill="#f5e5b5" stroke="#b79d6b" stroke-width="1.5"/><path d="m30 71-3 14m16-15-1 15m14-15 2 15m12-15 5 15M22 77h63" stroke="#c9b07c"/>' +
cube(29, 70, c.body, 9) +
cube(67, 77, colors[other].body, 9) +
die(90, 65, [
[6, 6],
[17, 17],
])
);
case "glutton":
return (
creature(13, -2, 92, 2, "hungry") +
'<ellipse cx="60" cy="85" rx="42" ry="12" fill="#fff8e0" stroke="#b4b187" stroke-width="2"/><ellipse cx="60" cy="85" rx="31" ry="7" fill="none" stroke="#dcd4b1"/>' +
cube(28, 73, food[0], 14) +
cube(46, 71, food[1], 14) +
cube(65, 74, food[2], 14) +
cube(54, 60, food[0], 14) +
sparkle(99, 40)
);
case "alarm":
return (
creature(28, 22, 75, 1) +
creature(1, 54, 36, 2, "movement", other) +
'<g transform="rotate(-12 31 26)"><path d="M14 38q8-7 7-21 0-14 13-14t13 14q-1 14 7 21Z" fill="#eed187" stroke="#ac8a43" stroke-width="2"/><path d="M14 38h40M29 42q5 7 10 0M32 0h4" fill="none" stroke="#ac8a43" stroke-width="2.5" stroke-linecap="round"/><path d="M10 13q-6 10 0 17m49-17q6 10 0 17" fill="none" stroke="#c29562" stroke-width="2"/></g>' +
arrows("M8 84H0m5-5-5 5 5 5", "#9aad8a")
);
case "cleanliness":
return (
tile(80, 59, 35, 34) +
creature(9, 4, 81, 1) +
'<path d="m55 76 21-40" stroke="#9d8058" stroke-width="5" stroke-linecap="round"/><path d="m43 82 14-15 13 7-4 22Z" fill="#e4c989" stroke="#a58a5c" stroke-width="1.8"/><path d="m52 78-5 10m10-7-3 11m8-8-2 9" stroke="#b39a65" stroke-width="1.4"/>' +
cube(85, 76, c.body, 10) +
cube(99, 70, c.body, 10) +
arrows("M69 60q13-7 24 0m-5-5 5 5-5 4") +
sparkle(15, 25) +
sparkle(99, 29, 9)
);
case "hard-crust":
return (
creature(14, 3, 91, 2, "crust") +
'<path d="m12 81 9-12 10 7 12-4 8 13-14 10-15-2Z" fill="#e0c592" stroke="#9d8059" stroke-width="2"/><path d="m21 71 6 12 13-8m-13 8 2 10m-2-10-12-1" fill="none" stroke="#b1976d" stroke-width="1.5"/>' +
sparkle(98, 34)
);
case "migration":
return (
forecast(75, 6, 11) +
creature(2, 14, 91, 1, "sensing") +
arrows("M91 64q-3 15-17 20m8-1-8 1 3-7", "#82aab0")
);
case "social":
return (
'<path d="M28 34q31-27 64 0M19 55q-1 25 22 29m64-30q-2 22-25 29" fill="none" stroke="#adc49a" stroke-width="2" stroke-dasharray="5 4"/>' +
creature(0, 12, 50, 0, "", other) +
creature(
76,
10,
47,
1,
"",
colonyColor === "yellow" ? "green" : "yellow",
) +
creature(32, 40, 67, 2) +
flask(32, 27, 21) +
flask(71, 28, 21) +
arrows("m38 52 9 6-1-8m32 3-9 6 1-8", "#9b9c66")
);
case "fast-food":
return (
arrows("M2 28h20M6 40h15", "#9bad8c") +
creature(21, 0, 82, 1, ["food", "movement"]) +
'<ellipse cx="26" cy="79" rx="23" ry="9" fill="#fff9e5" stroke="#b5b68c" stroke-width="1.8"/>' +
cube(18, 66, food[0], 13) +
arrows("M53 83h47m-8-8 8 8-8 8") +
'<path d="m10 58 3-5m-1 0h5" fill="none" stroke="#c09c4c" stroke-width="2"/>'
);
case "adaptable":
return (
geneCard(8, 38, "#e9edca", -11) +
geneCard(77, 35, "#d3e6d8", 12) +
creature(35, 0, 55, 1) +
arrows(
"M27 24q26-17 56-2m-6-6 7 6-9 2M89 86q-25 15-52 2m6 6-7-6 9-3",
"#829c83",
) +
sparkle(58, 66, 9)
);
case "mouthful":
return (
creature(0, 27, 49, 2, "hungry", other) +
creature(34, 3, 91, 0, "hungry") +
patch(74, 72, 18) +
'<path d="M27 33q-5-9-10-1-2 7 10 14 12-11 8-16-4-5-8 3Z" fill="#e5a18e" stroke="#b47c6b" stroke-width="1.6"/>'
);
case "camouflage1":
return (
leaf(2, 32, 31, -20) +
creature(14, 4, 86, 1, "camouflage") +
leaf(92, 49, 26, 17) +
leaf(18, 73, 25, -45) +
die(85, 74, [
[6, 6],
[17, 6],
[6, 17],
[17, 17],
])
);
case "camouflage2":
return (
leaf(1, 17, 34, -14) +
leaf(81, 3, 32, 13) +
creature(16, 5, 88, 1, "camouflage2") +
leaf(14, 77, 27, -52) +
leaf(85, 71, 31, 10) +
'<path d="m72 88 5 5 10-12" fill="none" stroke="#648458" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>'
);
case "suction1":
return (
tile(82, 61, 33, 34) +
creature(1, 0, 84, 0, "suction") +
arrows("M66 71q12-17 29-4", "#91b4a6") +
cube(88, 71, food[0], 14) +
'<path d="M81 77h-6m6 7-5 2" stroke="#92aea1" stroke-width="1.8" stroke-linecap="round"/>'
);
case "suction2":
return (
tile(84, 58, 33, 39) +
creature(0, 0, 83, 0, "suction2") +
cube(86, 64, food[0], 12) +
cube(100, 80, food[1], 12) +
arrows("M74 61q10-13 24-7", "#91b4a6") +
'<path d="m82 70-8 3m13 17-10-1" stroke="#92aea1" stroke-width="1.8" stroke-linecap="round"/>'
);
case "threat":
return (
creature(8, 0, 95, 2, "frill") +
creature(84, 60, 36, 1, "", other) +
arrows("M9 35 0 31m1 7-1-7 7-2M99 25l12-4m-7-4 8 4-3 7", "#b3946e")
);
case "flexible":
return (
'<path d="M13 68Q-7 5 54 17q71 10 40 69" fill="none" stroke="#a5b993" stroke-width="3" stroke-dasharray="5 4"/>' +
'<g transform="translate(5 0) skewX(-10)">' +
creature(25, 6, 80, 2) +
"</g>" +
'<g transform="rotate(13 90 77)"><path d="m70 61 35 0 11 17-11 17H70Z" fill="#f4e3ad" stroke="#b8a06b" stroke-width="1.8"/><circle cx="106" cy="78" r="2" fill="#b8a06b"/></g>' +
flask(72, 64, 23) +
'<path d="M96 78h8" stroke="#8b7854" stroke-width="2.5" stroke-linecap="round"/>'
);
case "healing1":
return (
creature(15, 2, 88, 0, "healing") +
'<rect x="5" y="69" width="35" height="26" rx="6" fill="#eaf1d9" stroke="#799980" stroke-width="1.8"/><path d="M15 68v-5h13v5" fill="none" stroke="#799980" stroke-width="2"/><path d="M22 75v13m-6.5-6.5h13" stroke="#619b82" stroke-width="4" stroke-linecap="round"/>' +
sparkle(100, 36)
);
case "healing2":
return (
creature(0, 1, 86, 0, "healing2") +
creature(76, 44, 45, 1, "", other) +
patch(88, 74, 15) +
arrows("M67 24q25-3 34 14m-1-9 2 10-10-2", "#88a996") +
sparkle(81, 15) +
patch(47, 80, 0)
);
case "rebound":
return (
'<path d="M49 91q-9-16-5-27 1-16 12-14 17-8 18 11 12 21 2 30Z" fill="#c2caa5" stroke="#8ea17e" stroke-width="2"/><path d="m51 62 8-3m4 18 6 8" fill="none" stroke="#a5b491" stroke-width="3" stroke-linecap="round"/>' +
creature(34, 0, 61, 1, "movement") +
arrows("M7 85Q10 13 46 17m33 8q24 18 25 59m-7-6 7 8 7-8", "#75a69b")
);
case "bang":
return (
'<path d="m59 1 10 20 23-12-2 24 29 0-16 21 17 18-28 3 2 27-25-13-13 16-8-24-28 9 8-25L0 55l24-12-13-23 29 4Z" fill="#f2d78f" stroke="#c5a068" stroke-width="2" stroke-linejoin="round"/><path d="m55 18 10 20 23-7-5 20 19 16-22 3-10 20-15-14-20 6 3-22-16-7 22-12Z" fill="#edb287"/>' +
creature(24, 14, 75, 2) +
patch(89, 78, 26) +
sparkle(16, 10, 6)
);
case "short-life":
return (
creature(0, 25, 73, 2) +
'<path d="M77 16h28m-28 64h28M79 19c0 22 12 17 12 29S79 60 79 77m24-58c0 22-12 17-12 29s12 12 12 29" fill="#f6eed3" stroke="#9d956b" stroke-width="2.5" stroke-linecap="round"/><path d="m84 29 7 12 7-12m-16 45 9-17 9 17Z" fill="#e6c771"/><path d="M91 44v8" stroke="#d4b059" stroke-width="2"/>' +
leaf(15, 4, 22, 30, "#d7c38c")
);
case "toxic":
return (
creature(14, 0, 88, 2, "toxic") +
'<path d="M30 79q-19-5-21 5-4 13 27 9 15 14 37 1 32 7 35-4 0-13-23-10-28-13-55-1Z" fill="#b9a0cd" fill-opacity=".8" stroke="#8f72a2" stroke-width="1.8"/><g fill="#e3ccec" stroke="#9272a4" stroke-width="1.5"><circle cx="39" cy="80" r="5"/><circle cx="66" cy="88" r="4"/><circle cx="88" cy="77" r="6"/><circle cx="95" cy="62" r="3"/></g>'
);
case "population":
return (
creature(0, 8, 43, 0) +
creature(77, 4, 44, 1) +
creature(43, -2, 37, 2) +
creature(1, 54, 46, 2) +
creature(80, 53, 43, 0) +
creature(24, 20, 78, 1) +
arrows("M12 49v-9m-4 4 4-4 4 4M107 47v-9m-4 4 4-4 4 4", "#98ad7a")
);
case "energy":
return (
'<path d="M7 66q19 15 34 0t34 0 34 0M3 83q19 15 34 0t34 0 34 0" fill="none" stroke="#a1c8b9" stroke-width="3" stroke-linecap="round"/>' +
'<g transform="rotate(-16 54 49)">' +
creature(12, 1, 84, 2) +
"</g>" +
flask(89, 54, 29) +
'<path d="M104 41v10m-5-5h10" stroke="#9ba969" stroke-width="2.2" stroke-linecap="round"/>' +
leaf(5, 74, 22, -28)
);
case "phd":
return (
creature(14, 6, 91, 0, ["glasses", "phd"]) +
'<g transform="rotate(-14 90 80)"><rect x="66" y="70" width="43" height="20" rx="5" fill="#fff3cf" stroke="#b4a078" stroke-width="1.6"/><path d="M73 71v17m29-16v16" stroke="#e0ce9d" stroke-width="2"/><path d="m87 72 0 18 4-3 4 3V72" fill="#dc9e88" stroke="#b87968" stroke-width="1"/></g>'
);
case "environmental":
return (
forecast(80, 6, 16, true) +
forecast(66, 9, -8, true) +
creature(0, 20, 90, 1, "sensing2") +
sparkle(111, 64, 6)
);
default:
return undefined;
}
}