blur layers

This commit is contained in:
2026-05-21 05:59:44 -04:00
parent 3983cf2e0d
commit 687a968522
42 changed files with 2895070 additions and 920162 deletions

View File

@@ -38,9 +38,11 @@ export function renderSVG(scene, params, sizePx = 4800) {
const glowOut = inv ? '#b3aa92' : '#070605';
const ink = inv ? '#1c1814' : '#e9e4d6';
// wrap content as a named, Inkscape/Affinity-compatible layer
const layer = (id, label, content) =>
content ? `<g id="${id}" inkscape:groupmode="layer" inkscape:label="${label}" style="display:inline">\n${content}\n</g>\n` : '';
// wrap content as a named, Inkscape/Affinity-compatible layer (label is an
// XML attribute → escape entities)
const attr = (t) => String(t).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
const layer = (id, label, content, extra = '') =>
content ? `<g id="${id}" inkscape:groupmode="layer" inkscape:label="${attr(label)}" style="display:inline"${extra ? ' ' + extra : ''}>\n${content}\n</g>\n` : '';
/* ---------- Background ---------- */
const bg = `<rect width="${w}" height="${h}" fill="${paper}"/>\n<rect width="${w}" height="${h}" fill="url(#paper)"/>`;
@@ -206,10 +208,10 @@ export function renderSVG(scene, params, sizePx = 4800) {
let s = `<?xml version="1.0" encoding="UTF-8"?>\n`;
s += `<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">\n`;
s += `<metadata>Bubble Chamber · seed=${params.seed} · hash=${cyrb53(params.seed)}</metadata>\n`;
s += defs(inv, paper, glowIn, glowOut, ink, params);
s += defs(inv, paper, glowIn, glowOut, ink, params, u);
s += layer('background', 'Background', bg);
s += layer('optics', 'Chamber optics', optics);
s += layer('shock', 'Shock disk', shock);
s += layer('shock', 'Shock disk', shock, params.diskSoften > 0 ? 'filter="url(#soften)"' : '');
s += trackLayers;
s += layer('damage', 'Plate damage', damage);
s += layer('fiducials', 'Fiducials', fids);
@@ -219,8 +221,12 @@ export function renderSVG(scene, params, sizePx = 4800) {
return s;
}
function defs(inv, paper, glowIn, glowOut, ink, params) {
function defs(inv, paper, glowIn, glowOut, ink, params, u) {
const soften = params.diskSoften > 0
? `<filter id="soften" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="${(params.diskSoften * u).toFixed(2)}"/></filter>`
: '';
return `<defs>
${soften}
<radialGradient id="paper" cx="50%" cy="42%" r="72%">
<stop offset="0%" stop-color="${glowIn}"/><stop offset="100%" stop-color="${glowOut}"/>
</radialGradient>