Some checks failed
Build & Release APK / build (push) Has been cancelled
The icon is now the session's hold ring rendered with depth: an open ring whose colour sweeps from a dim ember tail to a hot amber head, around a glowing core, on a warm radial-glow background. Android gets a matching adaptive background image (was a flat colour), a smaller themed-icon glyph, and regenerated launcher/splash res. store/icons/make.js is the source; the release signingConfigs block in build.gradle is untouched. CI: runs-on goes back to `desktop`. The VPS runner was retired on 2026-11-20, so ubuntu-latest jobs had nowhere safe to run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
6.8 KiB
JavaScript
133 lines
6.8 KiB
JavaScript
#!/usr/bin/env node
|
||
// Generate the app icon set from one SVG mark, rendered through headless Chrome.
|
||
//
|
||
// node store/icons/make.js
|
||
//
|
||
// Writes into assets/images/:
|
||
// icon.png 1024×1024 opaque (iOS + fallback)
|
||
// android-icon-background.png 1024×1024 opaque (adaptive background: ember glow)
|
||
// android-icon-foreground.png 1024×1024 alpha (adaptive foreground, mark in the 66dp safe zone)
|
||
// android-icon-monochrome.png 1024×1024 alpha (themed icon, white mark)
|
||
// splash-icon.png 512×512 alpha (splash, mark only)
|
||
//
|
||
// The mark is the hold ring from the session screen: an open ring whose colour
|
||
// sweeps from a dim ember tail to a hot amber head (the hold timer mid-squeeze),
|
||
// around a glowing core: "squeeze". Colours from src/lib/theme.ts. After running,
|
||
// regenerate the committed Android res with `npx expo prebuild -p android --no-install`
|
||
// and restore the release signingConfigs block in android/app/build.gradle from git.
|
||
|
||
const fs = require("fs");
|
||
const path = require("path");
|
||
const { execFileSync } = require("child_process");
|
||
|
||
const CHROME = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
|
||
const OUT = path.join(__dirname, "..", "..", "assets", "images");
|
||
const TMP = path.join(__dirname, ".tmp");
|
||
|
||
const C = { bg: "#160B0B", glow: "#3B1612", edge: "#0D0606" };
|
||
// ring colour along the sweep: tail → head
|
||
const SWEEP = [[0, "#9E2418"], [0.5, "#DE3A2B"], [0.82, "#F6612F"], [1, "#FFA94D"]];
|
||
const RING = { start: 38, sweep: 292 }; // degrees clockwise from 12 o'clock; the gap sits over the top
|
||
|
||
const hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));
|
||
function mix(t) {
|
||
for (let i = 0; i < SWEEP.length - 1; i++) {
|
||
const [p0, c0] = SWEEP[i];
|
||
const [p1, c1] = SWEEP[i + 1];
|
||
if (t <= p1) {
|
||
const k = p1 === p0 ? 0 : (t - p0) / (p1 - p0);
|
||
const [a, b] = [hex(c0), hex(c1)];
|
||
return "#" + a.map((x, j) => Math.round(x + (b[j] - x) * k).toString(16).padStart(2, "0")).join("");
|
||
}
|
||
}
|
||
return SWEEP[SWEEP.length - 1][1];
|
||
}
|
||
const pt = (c, r, deg) => {
|
||
const a = ((deg - 90) * Math.PI) / 180;
|
||
return [c + r * Math.cos(a), c + r * Math.sin(a)];
|
||
};
|
||
const f = (n) => n.toFixed(2);
|
||
|
||
function background(size) {
|
||
return `<defs><radialGradient id="kb" cx="50%" cy="46%" r="70%">
|
||
<stop offset="0" stop-color="${C.glow}"/><stop offset="0.6" stop-color="${C.bg}"/><stop offset="1" stop-color="${C.edge}"/>
|
||
</radialGradient></defs><rect width="${size}" height="${size}" fill="url(#kb)"/>`;
|
||
}
|
||
|
||
// size: canvas px; scale: fraction of the canvas the ring spans.
|
||
function mark(size, scale, { mono = false, glow = true } = {}) {
|
||
const c = size / 2;
|
||
const R = (size * scale) / 2; // outer radius
|
||
const sw = R * 0.3;
|
||
const rr = R - sw / 2;
|
||
const core = R * 0.3;
|
||
const { start, sweep } = RING;
|
||
if (mono) {
|
||
const [x0, y0] = pt(c, rr, start);
|
||
const [x1, y1] = pt(c, rr, start + sweep);
|
||
return `<path d="M${f(x0)} ${f(y0)} A${rr} ${rr} 0 1 1 ${f(x1)} ${f(y1)}" fill="none" stroke="#fff"
|
||
stroke-width="${sw}" stroke-linecap="round"/><circle cx="${c}" cy="${c}" r="${core}" fill="#fff"/>`;
|
||
}
|
||
// SVG has no sweep gradient: draw the arc as short segments, each in its own colour.
|
||
const n = 180;
|
||
let ring = "";
|
||
for (let i = 0; i < n; i++) {
|
||
const [x0, y0] = pt(c, rr, start + (sweep * i) / n);
|
||
const [x1, y1] = pt(c, rr, start + (sweep * (i + 1)) / n + 0.6); // slight overlap hides seams
|
||
ring += `<path d="M${f(x0)} ${f(y0)} A${rr} ${rr} 0 0 1 ${f(x1)} ${f(y1)}" fill="none" stroke="${mix((i + 0.5) / n)}" stroke-width="${sw}"/>`;
|
||
}
|
||
const [tx, ty] = pt(c, rr, start);
|
||
const [hx, hy] = pt(c, rr, start + sweep);
|
||
ring += `<circle cx="${f(tx)}" cy="${f(ty)}" r="${sw / 2}" fill="${SWEEP[0][1]}"/>`;
|
||
return `
|
||
<defs>
|
||
<filter id="kg" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="${R * 0.1}"/></filter>
|
||
<filter id="kg2" x="-80%" y="-80%" width="260%" height="260%"><feGaussianBlur stdDeviation="${R * 0.16}"/></filter>
|
||
<radialGradient id="kc" cx="0.42" cy="0.38" r="0.7"><stop offset="0" stop-color="#FFD2A1"/>
|
||
<stop offset="0.45" stop-color="#FF7A3C"/><stop offset="1" stop-color="#E2392A"/></radialGradient>
|
||
<radialGradient id="kh" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="#FFF3E0"/>
|
||
<stop offset="0.6" stop-color="#FFC178"/><stop offset="1" stop-color="#FFA94D"/></radialGradient>
|
||
</defs>
|
||
${glow ? `<g filter="url(#kg)" opacity="0.55">${ring}</g>
|
||
<circle cx="${c}" cy="${c}" r="${core * 1.6}" fill="#FF5A2F" opacity="0.45" filter="url(#kg2)"/>
|
||
<circle cx="${f(hx)}" cy="${f(hy)}" r="${sw * 0.9}" fill="#FFA94D" opacity="0.6" filter="url(#kg)"/>` : ""}
|
||
${ring}
|
||
<circle cx="${f(hx)}" cy="${f(hy)}" r="${sw / 2}" fill="url(#kh)"/>
|
||
<circle cx="${c}" cy="${c}" r="${core}" fill="url(#kc)"/>`;
|
||
}
|
||
|
||
const svg = (size, body) =>
|
||
`<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${body}</svg>`;
|
||
|
||
function render(svgText, size, out, transparent) {
|
||
fs.mkdirSync(TMP, { recursive: true });
|
||
const file = path.join(TMP, path.basename(out, ".png") + ".html");
|
||
fs.writeFileSync(
|
||
file,
|
||
`<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;width:${size}px;height:${size}px;overflow:hidden;background:${transparent ? "transparent" : C.bg}}svg{display:block}</style></head><body>${svgText}</body></html>`,
|
||
);
|
||
const args = [
|
||
"--headless=new", "--disable-gpu", "--hide-scrollbars", "--force-device-scale-factor=1",
|
||
`--window-size=${size},${size}`, `--screenshot=${out}`,
|
||
];
|
||
if (transparent) args.push("--default-background-color=00000000");
|
||
args.push("file://" + file);
|
||
execFileSync(CHROME, args, { stdio: "ignore" });
|
||
}
|
||
|
||
function main() {
|
||
// iOS: opaque, ring spans 64% of the canvas (Apple masks the corners itself).
|
||
render(svg(1024, background(1024) + mark(1024, 0.64)), 1024, path.join(OUT, "icon.png"), false);
|
||
// Android adaptive: ember-glow background + ring inside the 66dp safe circle.
|
||
render(svg(1024, background(1024)), 1024, path.join(OUT, "android-icon-background.png"), false);
|
||
render(svg(1024, mark(1024, 0.5)), 1024, path.join(OUT, "android-icon-foreground.png"), true);
|
||
// Android monochrome: white silhouette, a little smaller than the colour mark (themed icons read lighter).
|
||
render(svg(1024, mark(1024, 0.42, { mono: true })), 1024, path.join(OUT, "android-icon-monochrome.png"), true);
|
||
// Splash: mark only, on transparent; app.json sets the background colour.
|
||
render(svg(512, mark(512, 0.86, { glow: false })), 512, path.join(OUT, "splash-icon.png"), true);
|
||
fs.rmSync(TMP, { recursive: true, force: true });
|
||
console.log("wrote icon.png, android-icon-background.png, android-icon-foreground.png, android-icon-monochrome.png, splash-icon.png");
|
||
}
|
||
|
||
main();
|