fix(pdf): widen the halo glow so main-view selections read from across the page

Single 6px Gaussian blur was being attenuated to near-invisible by the
SVG → canvas → PNG → pdf-lib pipeline (each stage loses some alpha).
The halo is now built from two stacked passes:

- a wide pass (stdDeviation=18) merged three times for the outer glow,
- a tighter pass (stdDeviation=8) merged twice to keep the selection
  anchored to the original point instead of dissolving into a fog.

Result: zone highlights stay obvious at print scale and from a couple
of feet away. Detail-view rendering is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude committed 2026-05-20 05:21:43 +02:00
1 parent add408eee4
commit 4f8ea9e691
1 file changed
+30 -14
+30 -14
View File
@@ -82,22 +82,38 @@ function ensureHaloFilter(root: SVGSVGElement): void {
filter.setAttribute('height', '300%') filter.setAttribute('height', '300%')
filter.setAttribute('filterUnits', 'userSpaceOnUse') filter.setAttribute('filterUnits', 'userSpaceOnUse')
const blur = doc.createElementNS(SVG_NS, 'feGaussianBlur') // Two-stage blur: a wide outer halo for "spotted from across the
blur.setAttribute('in', 'SourceGraphic') // room" visibility, plus a tighter inner halo that keeps the
blur.setAttribute('stdDeviation', '6') // selection anchored to the original point so it doesn't dissolve.
blur.setAttribute('result', 'halo') const wide = doc.createElementNS(SVG_NS, 'feGaussianBlur')
filter.appendChild(blur) wide.setAttribute('in', 'SourceGraphic')
wide.setAttribute('stdDeviation', '18')
wide.setAttribute('result', 'haloWide')
filter.appendChild(wide)
const tight = doc.createElementNS(SVG_NS, 'feGaussianBlur')
tight.setAttribute('in', 'SourceGraphic')
tight.setAttribute('stdDeviation', '8')
tight.setAttribute('result', 'haloTight')
filter.appendChild(tight)
const merge = doc.createElementNS(SVG_NS, 'feMerge') const merge = doc.createElementNS(SVG_NS, 'feMerge')
const m1 = doc.createElementNS(SVG_NS, 'feMergeNode') // Stack the wide halo three times so its contribution survives the
m1.setAttribute('in', 'halo') // canvg → PNG → pdf-lib pipeline (each pass attenuates alpha) and
const m2 = doc.createElementNS(SVG_NS, 'feMergeNode') // still reads as a strong glow at print scale.
m2.setAttribute('in', 'halo') for (let i = 0; i < 3; i += 1) {
const m3 = doc.createElementNS(SVG_NS, 'feMergeNode') const n = doc.createElementNS(SVG_NS, 'feMergeNode')
m3.setAttribute('in', 'SourceGraphic') n.setAttribute('in', 'haloWide')
merge.appendChild(m1) merge.appendChild(n)
merge.appendChild(m2) }
merge.appendChild(m3) for (let i = 0; i < 2; i += 1) {
const n = doc.createElementNS(SVG_NS, 'feMergeNode')
n.setAttribute('in', 'haloTight')
merge.appendChild(n)
}
const source = doc.createElementNS(SVG_NS, 'feMergeNode')
source.setAttribute('in', 'SourceGraphic')
merge.appendChild(source)
filter.appendChild(merge) filter.appendChild(merge)
defs.appendChild(filter) defs.appendChild(filter)