Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(glass): app-painted terminal backgrounds become tinted glass
iceclatterWT228248f02874
diff --git a/CLAUDE.md b/CLAUDE.mdindex de3cdbf3b..2b1e48df0 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -3851,6 +3851,25 @@ glass never sits over plain black; a wallpaper the user chose is never replaced.mounted (it paints text BELOW the nodes, so a tint would cover it), and the blur is dropped whilethe camera moves (`.canvas-moving`, toggled by `onMoveStart`/`onMoveEnd` via classList so a pandoes not re-render Canvas) — the tint alone carries the contrast guarantee.+- **App-painted cell backgrounds become glass** (`terminal/glass-cell-backgrounds.ts`). addon-webgl+ 0.18.0 paints every background rectangle at alpha 1 (`RectangleRenderer._updateRectangle`,+ `$a = 1`), so full-screen TUIs read as slabs: Grok's `48;2;20;20;20` screen fill, Codex's composer,+ Claude's bubble — and, worse, every DIM/ITALIC/hyperlink run on the DEFAULT bg, because those flags+ live in the bg word and the run gets a theme-background rectangle at alpha 1 (Codex's all-dim+ header box). No xterm option exists, so the private method is wrapped on the shared prototype+ (installed from `acquireWebgl`, original kept under a `Symbol.for` key so a hot reload never+ double-wraps; fail-open). Per run: inverse → opaque; attribute-only (default bg) → the theme bg's+ alpha (0 under glass); rendered bg ≠ the buffer cell's raw bg = a renderer override (selection,+ block cursor, search/decoration) → opaque; a panel nearer the theme fg than its bg (light bar on a+ dark theme) → opaque; else the node's tint alpha (`GlassTint.alpha`, so the slider and Reduce+ Transparency apply). Written premultiplied as `(c·√k, √k)` — the canvas is premultiplied and the+ addon blends alpha with SRC_ALPHA, so this stores exactly `(c·k, k)`. Only terminals registered+ through `setGlassCellAlpha` (TerminalNode, `glassOn` only) are touched — others are byte-identical;+ an alpha change calls `term.clearTextureAtlas()` because backgrounds only rebuild for changed+ cells. The test pins addon-webgl 0.18.0 and every private name — an upgrade must re-derive them+ (or delete the wrap if upstream honours bg alpha). Ceilings: panels stack on the node tint+ (Grok reads denser than a shell); the DOM-renderer fallback keeps explicit backgrounds opaque+ (inline truecolor `background-color`).- **Liquid Glass chrome** (`:root[data-nt-glass='on']`, set by App.tsx only for that appearance, soevery other look is byte-identical). ONE chrome fill, `--glass-chrome-bg` = the resolved `--panel`at `glassChromeAlpha(--text, --panel)` — **dark 0.70, light 0.745** on the shipped palettes. Thediff --git a/src/renderer/lib/glassContrast.ts b/src/renderer/lib/glassContrast.tsindex 271df84e6..949286eb3 100644--- a/src/renderer/lib/glassContrast.ts+++ b/src/renderer/lib/glassContrast.ts@@ -158,6 +158,9 @@ export interface GlassTint {/** The theme foreground: header text sits on the TERMINAL's tint, so it takes the terminal's* text colour, not the app's (a light app theme over a dark terminal theme measured 1.31:1). */foreground: string+ /** The fill's alpha as a number — app-painted cell backgrounds follow it+ * (`terminal/glass-cell-backgrounds.ts`). */+ alpha: number}/** CSS for a theme's glass at a Glass-slider position (default: the Readable tick), or null when@@ -179,7 +182,8 @@ export function glassTint(background: `rgba(${rgb}, ${alpha.toFixed(3)})`,header: `rgba(${rgb}, ${HEADER_LAYER_ALPHA})`,chipWash: `${Math.round(chipWash * 100)}%`,- foreground+ foreground,+ alpha}}diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex d9020642a..360912288 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -3,6 +3,7 @@ import { FIND_DECORATIONS } from '../lib/palette'import { ptyRefusal } from '@shared/pty-refusal'import { patchImeModeSwitch } from '../terminal/ime-mode-switch'+import { installGlassCellBackgrounds, setGlassCellAlpha } from '../terminal/glass-cell-backgrounds'import { deliverRelayInitialLaunch } from '../terminal/relay-initial-launch'import { commitLaunch } from '../terminal/launch-attempt'@@ -1252,18 +1253,25 @@ export function TerminalNode({const glass = isLiquidGlass(useSettings((s) => s.settings.appTheme))const glassSlider = resolveGlassSlider(useSettings((s) => s.settings.glassTint))const glassA11y = useGlassA11y()- const glassVars = useMemo(() => {- if (!glass) return null- const tint = glassTint(resolveTerminalTheme(visual.terminalTheme).theme, glassSlider, glassA11y)- return tint- ? ({- '--term-glass-bg': tint.background,- '--term-glass-header-bg': tint.header,- '--term-glass-chip-wash': tint.chipWash,- '--term-glass-fg': tint.foreground- } as React.CSSProperties)- : null- }, [glass, glassSlider, glassA11y, visual.terminalTheme])+ const tint = useMemo(+ () => (glass ? glassTint(resolveTerminalTheme(visual.terminalTheme).theme, glassSlider, glassA11y) : null),+ [glass, glassSlider, glassA11y, visual.terminalTheme]+ )+ const glassVars = useMemo(+ () =>+ tint+ ? ({+ '--term-glass-bg': tint.background,+ '--term-glass-header-bg': tint.header,+ '--term-glass-chip-wash': tint.chipWash,+ '--term-glass-fg': tint.foreground+ } as React.CSSProperties)+ : null,+ [tint]+ )+ // The alpha app-painted cell backgrounds follow on this node (null = not glass, stock rendering).+ // A ref too, because `acquireWebgl` (inside the lifecycle closure) syncs every fresh addon to it.+ const glassCellAlphaRef = useRef<number | null>(null)// The account list, for the chip and for the READERS below: a config dir the user links while// this pane sits quiet must resolve to its new account immediately, not at the next hook event.const claudeAccounts = useSettings((s) => s.settings.claudeAccounts)@@ -2284,6 +2292,10 @@ export function TerminalNode({})term.loadAddon(a)webgl = a+ // Glass: app-painted cell backgrounds become tinted glass (glass-cell-backgrounds.ts). A+ // fresh addon starts from an empty model, so the repaint below already applies the alpha.+ installGlassCellBackgrounds(a)+ setGlassCellAlpha(term, glassCellAlphaRef.current)// THE RESTORE PATH — rebuild, never trust the addon's in-place recovery.//// When the GPU process resets (returning from a GPU-heavy app; sleep/wake; memory@@ -4863,6 +4875,16 @@ export function TerminalNode({if (themeChanged) fullRepaintRef.current?.()}, [visual, glass])+ // Glass cell backgrounds follow the node's tint alpha (slider, Reduce Transparency). Backgrounds+ // are only recomputed for CHANGED cells, so an alpha change rebuilds the WebGL model; the shared+ // glyph grid stands glass down, and so does this.+ const glassCellAlpha = tint && !glyphMounted ? tint.alpha : null+ useEffect(() => {+ glassCellAlphaRef.current = glassCellAlpha+ const term = termRef.current+ if (term && setGlassCellAlpha(term, glassCellAlpha)) term.clearTextureAtlas()+ }, [glassCellAlpha])+// glyphgrid participation — whether this node should hold a grid RIGHT NOW.//// ORDERING IS THE POINT, and it is why this effect is declared HERE, immediately after the onediff --git a/src/renderer/terminal/glass-cell-backgrounds.test.ts b/src/renderer/terminal/glass-cell-backgrounds.test.tsnew file mode 100644index 000000000..5e75ca80b--- /dev/null+++ b/src/renderer/terminal/glass-cell-backgrounds.test.ts@@ -0,0 +1,166 @@+import { describe, expect, it } from 'vitest'+import fs from 'fs'+import path from 'path'+import type { Terminal } from '@xterm/xterm'+import type { WebglAddon } from '@xterm/addon-webgl'+import { glassRectAlpha, installGlassCellBackgrounds, setGlassCellAlpha } from './glass-cell-backgrounds'+import { relativeLuminance } from '../lib/glassContrast'++const INVERSE = 0x4000000+const CM_P256 = 0x2000000+const CM_RGB = 0x3000000+const DIM = 0x8000000+const ITALIC = 0x4000000+const HAS_EXTENDED = 0x10000000++const BG_LUM = relativeLuminance([30, 30, 30]) // nodeterm-dark background+const FG_LUM = relativeLuminance([212, 212, 212])+const L = (v: number): number => relativeLuminance([v, v, v])++describe('glassRectAlpha', () => {+ const grok = CM_RGB | 0x141414+ it.each([+ ['inverse video / fake cursor', INVERSE, CM_RGB | 0x3a3a3a, CM_RGB | 0x3a3a3a, L(58), 1],+ ['inverse on the default bg', INVERSE, 0, 0, FG_LUM, 1],+ ['DIM on the default bg', 0, DIM, DIM, BG_LUM, 0],+ ['ITALIC on the default bg', 0, ITALIC, ITALIC, BG_LUM, 0],+ ['hyperlink / underline style on the default bg', 0, HAS_EXTENDED, HAS_EXTENDED, BG_LUM, 0],+ ['app panel (truecolor)', 0, grok, grok, L(20), 0.4],+ ['app panel (256-colour, Claude bubble)', 0, CM_P256 | 237, CM_P256 | 237, L(58), 0.4],+ ['dim text on an app panel', 0, grok | DIM, grok | DIM, L(20), 0.4],+ ['selection / block cursor / search highlight (renderer override)', 0, CM_RGB | 0x264f78, grok, relativeLuminance([38, 79, 120]), 1],+ ['override where the buffer cell was unreadable', 0, grok, NaN, L(20), 1],+ ['light panel on a dark theme', 0, CM_RGB | 0xe0e0e0, CM_RGB | 0xe0e0e0, L(224), 1]+ ])('%s', (_name, fg, bg, cellBg, runLum, want) => {+ expect(glassRectAlpha(fg, bg, cellBg, 0.4, 0, runLum, BG_LUM, FG_LUM)).toBe(want)+ })++ it('an attribute-only run takes the theme background alpha, whatever it is', () => {+ expect(glassRectAlpha(0, DIM, DIM, 0.4, 1, BG_LUM, BG_LUM, FG_LUM)).toBe(1)+ })++ it('Reduce Transparency (node alpha 1) leaves app panels opaque', () => {+ expect(glassRectAlpha(0, CM_RGB | 0x141414, CM_RGB | 0x141414, 1, 0, L(20), BG_LUM, FG_LUM)).toBe(1)+ })+})++it('(c·√k, √k) blended SRC_ALPHA over a cleared premultiplied canvas stores exactly (c·k, k)', () => {+ for (const k of [0.2, 0.675, 0.95]) {+ const c = 20 / 255+ const s = Math.sqrt(k)+ expect(c * s * s).toBeCloseTo(c * k, 12) // rgb: src·srcAlpha+ expect(s * s).toBeCloseTo(k, 12) // alpha channel blends the same way+ }+})++it('setGlassCellAlpha reports only real changes', () => {+ const t = {} as Terminal+ expect(setGlassCellAlpha(t, 0.2)).toBe(true)+ expect(setGlassCellAlpha(t, 0.2)).toBe(false)+ expect(setGlassCellAlpha(t, 0.95)).toBe(true)+ expect(setGlassCellAlpha(t, null)).toBe(true)+ expect(setGlassCellAlpha(t, null)).toBe(false)+})++/** A structural fake of the addon's RectangleRenderer, doing what the real `_updateRectangle`+ * does with the attribute array (colour, then `$a = 1`). One class per test: the wrap patches the+ * prototype, like it does the real shared one. */+function fakeAddon(cells: Record<number, number>) {+ class RectangleRenderer {+ _themeService = { colors: { background: { rgba: 0x1e1e1e00 }, foreground: { rgba: 0xd4d4d4ff } } }+ _terminal = {+ buffer: {+ active: {+ viewportY: 0,+ getNullCell: () => ({ bg: 0 }),+ getLine: () => ({+ getCell: (x: number, cell: { bg: number }) => {+ cell.bg = cells[x] ?? 0+ return cell+ }+ })+ }+ }+ } as unknown as Terminal+ _updateRectangle(v: { attributes: Float32Array }, offset: number, fg: number, bg: number, _startX: number, _endX: number, _y: number): void {+ const rgba = bg & CM_RGB ? (bg & 0xffffff) << 8 : this._themeService.colors.background.rgba+ v.attributes.set([0, 0, 1, 1, ((rgba >>> 24) & 255) / 255, ((rgba >>> 16) & 255) / 255, ((rgba >>> 8) & 255) / 255, 1], offset)+ void fg+ }+ }+ const rr = new RectangleRenderer()+ const addon = { _renderer: { _rectangleRenderer: { value: rr } } } as unknown as WebglAddon+ const draw = (fg: number, bg: number, x = 0): number[] => {+ const v = { attributes: new Float32Array(8) }+ rr._updateRectangle(v, 0, fg, bg, x, x + 1, 0)+ return Array.from(v.attributes)+ }+ return { addon, rr, draw, proto: RectangleRenderer.prototype }+}++describe('installGlassCellBackgrounds', () => {+ const panel = CM_RGB | 0x141414++ it('glass: an app panel is premultiplied to the node alpha, a dim run vanishes, an override stays', () => {+ const { addon, rr, draw } = fakeAddon({ 0: panel })+ expect(installGlassCellBackgrounds(addon)).toBe(true)+ setGlassCellAlpha(rr._terminal, 0.25)+ const p = draw(0, panel)+ expect(p[7]).toBeCloseTo(0.5, 6) // √0.25+ expect(p[4]).toBeCloseTo((20 / 255) * 0.5, 6)+ expect(draw(0, DIM)[7]).toBe(0)+ expect(draw(0, CM_RGB | 0x264f78)[7]).toBe(1) // rendered bg ≠ buffer bg: selection+ expect(draw(INVERSE, panel)[7]).toBe(1)+ })++ it('non-glass terminals are byte-identical to the stock renderer', () => {+ const stock = fakeAddon({ 0: panel })+ const wrapped = fakeAddon({ 0: panel })+ installGlassCellBackgrounds(wrapped.addon)+ for (const [fg, bg] of [[0, panel], [0, DIM], [INVERSE, panel], [0, CM_RGB | 0x264f78]]) {+ expect(wrapped.draw(fg, bg)).toEqual(stock.draw(fg, bg))+ }+ })++ it('a re-install (hot reload) wraps the original, never the wrap', () => {+ const { addon, rr, draw } = fakeAddon({ 0: panel })+ installGlassCellBackgrounds(addon)+ installGlassCellBackgrounds(addon)+ setGlassCellAlpha(rr._terminal, 0.25)+ expect(draw(0, panel)[7]).toBeCloseTo(0.5, 6) // applied once, not √√+ })++ it('fails open when the internals are missing', () => {+ expect(installGlassCellBackgrounds({} as WebglAddon)).toBe(false)+ expect(installGlassCellBackgrounds({ _renderer: { _rectangleRenderer: { value: {} } } } as unknown as WebglAddon)).toBe(false)+ })+})++/**+ * Guard: the wrap leans on addon-webgl PRIVATES. An upgrade must fail here, loudly, instead of+ * silently falling back to opaque slabs (the wrap fails open). If this fails: re-read+ * `src/RectangleRenderer.ts` of the new version, re-derive the names in glass-cell-backgrounds.ts+ * — or delete the wrap if upstream now honours background alpha.+ */+describe('addon-webgl internals the glass cell wrap relies on', () => {+ const dir = path.resolve(__dirname, '../../../node_modules/@xterm/addon-webgl')+ const bundle = fs.readFileSync(path.join(dir, 'lib/addon-webgl.js'), 'utf8')++ it('is the pinned 0.18.0', () => {+ expect(JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).version).toBe('0.18.0')+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../../package.json'), 'utf8'))+ expect({ ...pkg.dependencies, ...pkg.devDependencies }['@xterm/addon-webgl']).toBe('0.18.0')+ })++ it.each([+ 'this._renderer=', // WebglAddon._renderer+ '_rectangleRenderer.value=new', // WebglRenderer._rectangleRenderer (a MutableDisposable)+ '_updateRectangle(e,t,i,s,r,o,a){', // (vertices, offset, fg, bg, startX, endX, y)+ 'updateBackgrounds(',+ 'this._terminal=e,this._gl=t,this._dimensions=i,this._themeService', // RectangleRenderer fields+ 'e[t+4]=n,e[t+5]=a,e[t+6]=h,e[t+7]=l', // _addRectangle: r,g,b,a at offset+4..7+ 'v=1,this._addRectangle(e.attributes,t,' // the forced alpha 1 the wrap rewrites; gone = fixed upstream?+ ])('bundle contains %s', (needle) => {+ expect(bundle).toContain(needle)+ })+})diff --git a/src/renderer/terminal/glass-cell-backgrounds.ts b/src/renderer/terminal/glass-cell-backgrounds.tsnew file mode 100644index 000000000..4b6699da5--- /dev/null+++ b/src/renderer/terminal/glass-cell-backgrounds.ts@@ -0,0 +1,162 @@+import type { Terminal } from '@xterm/xterm'+import type { WebglAddon } from '@xterm/addon-webgl'+import { relativeLuminance } from '../lib/glassContrast'++/**+ * Cell backgrounds on a Liquid Glass terminal become glass instead of opaque slabs.+ *+ * addon-webgl 0.18.0 paints every background rectangle at alpha 1 (`RectangleRenderer.+ * _updateRectangle`: `$a = 1`), whatever the colour came from. Under glass the viewport itself is+ * transparent, so two things read as black/grey cards over the wallpaper:+ * - app-painted backgrounds (Grok's full-screen `48;2;20;20;20`, Codex's composer, Claude's+ * user bubble), and+ * - attribute-only runs: DIM / ITALIC / HAS_EXTENDED live in the bg word, so a dim run on the+ * DEFAULT background still gets a rectangle, filled with the theme background at alpha 1+ * (Codex's all-dim header box). That half is an xterm bug for any `allowTransparency` user.+ *+ * xterm has no option for either (`allowTransparency` is all there is, and palette alpha is+ * ignored), so this wraps the private `_updateRectangle` on the shared prototype and rewrites the+ * alpha the original just wrote — the same private coupling a bundle patch would need, minus the+ * postinstall and Vite pre-bundle cache. Fail-open like `dom-renderer-spacing.ts`: a build that+ * renamed anything keeps stock rendering. `glass-cell-backgrounds.test.ts` pins the addon version+ * and every private name used here.+ *+ * Only terminals given an alpha through `setGlassCellAlpha` are touched; for every other terminal+ * the wrap returns right after the original, so non-glass output is byte-identical.+ *+ * Ceiling: the DOM renderer fallback (WebGL budget exhausted / context lost) keeps opaque explicit+ * backgrounds — its inline truecolor `background-color` cannot be re-alpha'd from CSS.+ */++// xterm's packed attribute bits (common/buffer/Constants.ts).+const FG_INVERSE = 0x4000000+const CM_MASK = 0x3000000++/** ponytail: tuning knob, panel alpha = node tint alpha × this. 0.5 measured 5.6:1 at Readable+ * over a bright backdrop (tui-glass-backgrounds.md), so 1 — lower only with a new contrast check. */+const CELL_ALPHA_SCALE = 1++/**+ * The alpha one background run gets on a glass terminal.+ * - inverse video (and the fake cursors TUIs draw with it) stays opaque;+ * - an attribute-only run (default bg + DIM/ITALIC/…) gets the theme background's alpha, which is+ * what the rest of the viewport gets (0 under glass);+ * - a rendered bg that differs from the buffer cell's raw bg is a RENDERER override — selection,+ * the block cursor, a search/decoration highlight — and stays opaque;+ * - a panel nearer the theme foreground than the background (a light bar on a dark theme) stays+ * opaque, since fading it would move the text on it toward the tint;+ * - everything else is the app's own panel and follows the node's glass alpha, so the Glass slider+ * and Reduce Transparency (alpha 1) apply to it like to the node.+ */+export function glassRectAlpha(+ fg: number,+ bg: number,+ cellBg: number,+ glassA: number,+ themeBgA: number,+ runLum: number,+ bgLum: number,+ fgLum: number+): number {+ if (fg & FG_INVERSE) return 1+ if ((bg & CM_MASK) === 0) return themeBgA+ if (bg !== cellBg) return 1+ if (Math.abs(runLum - bgLum) > Math.abs(runLum - fgLum)) return 1+ return Math.min(1, glassA * CELL_ALPHA_SCALE)+}++/** The node's glass alpha per terminal; absent = not glass = stock rendering. */+const cellAlpha = new WeakMap<Terminal, number>()++/** Set (or clear with null) a terminal's glass alpha. True when it changed — the caller then owes a+ * model rebuild (`term.clearTextureAtlas()`), since backgrounds are only recomputed for changed+ * cells. */+export function setGlassCellAlpha(term: Terminal, alpha: number | null): boolean {+ if (alpha === null) return cellAlpha.delete(term)+ if (cellAlpha.get(term) === alpha) return false+ cellAlpha.set(term, alpha)+ return true+}++type Vertices = { attributes: Float32Array }+type UpdateRectangle = (+ v: Vertices,+ offset: number,+ fg: number,+ bg: number,+ startX: number,+ endX: number,+ y: number+) => void+interface RectangleRendererLike {+ _terminal: Terminal+ _themeService?: { colors?: { background?: { rgba: number }; foreground?: { rgba: number } } }+}++/** Kept on the prototype, not in module state, so a hot-reloaded copy of this module re-wraps the+ * ORIGINAL instead of stacking a second wrap over the first. */+const ORIGINAL = Symbol.for('nodeterm.glassCellBackgrounds.original')++const lum = (rgba: number): number => relativeLuminance([(rgba >>> 24) & 255, (rgba >>> 16) & 255, (rgba >>> 8) & 255])++/** Wrap the addon's rectangle renderer once (all instances share the prototype). Call after+ * `term.loadAddon(addon)`, when the renderer exists. Returns whether the wrap is in place. */+export function installGlassCellBackgrounds(addon: WebglAddon): boolean {+ try {+ const rr = (addon as unknown as { _renderer?: { _rectangleRenderer?: { value?: object } } })._renderer+ ?._rectangleRenderer?.value+ const proto = rr && (Object.getPrototypeOf(rr) as Record<PropertyKey, unknown>)+ if (!proto) return false+ const orig = (proto[ORIGINAL] ?? proto._updateRectangle) as UpdateRectangle | undefined+ if (typeof orig !== 'function') return false+ proto[ORIGINAL] = orig+ let scratch: { bg?: number } | undefined+ proto._updateRectangle = function (+ this: RectangleRendererLike,+ v: Vertices,+ offset: number,+ fg: number,+ bg: number,+ startX: number,+ endX: number,+ y: number+ ): void {+ orig.call(this, v, offset, fg, bg, startX, endX, y)+ const glassA = cellAlpha.get(this._terminal)+ if (glassA === undefined) return+ const colors = this._themeService?.colors+ const back = colors?.background?.rgba+ const fore = colors?.foreground?.rgba+ if (back === undefined || fore === undefined) return+ const a = v.attributes // re-read: the original may have grown the array+ let cellBg = NaN // unknown = treated as a renderer override (stock opaque)+ if ((bg & CM_MASK) !== 0 && !(fg & FG_INVERSE)) {+ const buf = this._terminal.buffer.active+ scratch ??= buf.getNullCell() as unknown as { bg?: number }+ buf.getLine(buf.viewportY + y)?.getCell(startX, scratch as never)+ if (typeof scratch.bg === 'number') cellBg = scratch.bg+ }+ const k = glassRectAlpha(+ fg,+ bg,+ cellBg,+ glassA,+ (back & 255) / 255,+ relativeLuminance([a[offset + 4] * 255, a[offset + 5] * 255, a[offset + 6] * 255]),+ lum(back),+ lum(fore)+ )+ if (k >= 1) return+ // The canvas is premultiplied and the addon blends SRC_ALPHA/ONE_MINUS_SRC_ALPHA on the alpha+ // channel too, so writing (c, k) would store (c·k, k²). (c·√k, √k) stores exactly (c·k, k).+ const s = Math.sqrt(k)+ a[offset + 4] *= s+ a[offset + 5] *= s+ a[offset + 6] *= s+ a[offset + 7] = s+ }+ return true+ } catch {+ return false+ }+}