Skip to content

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.

fix(glyphgrid): source gutter extension from the last fully-covered texel; fractional-cell pins

enesb57b1de93644
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
index fe7277ab9..aca8ffa17 100644
--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
@@ -153,12 +153,23 @@ Auto after you switched builds, that is why: re-select Shared and carry on.
mip texel was averaging the cell's edge INK with the slot's flat background gutter — so a solid
block of mascot came out as a dark lattice. Seams coming back is a **blocking** report: say at
which zoom, and whether the dips track the cell pitch.
- **Expected residual 0 — two adjacent full-bleed slots.** At the worst subpixel phase and mip
- level 2, a bilinear tap can reach a gutter texel blending THIS slot's edge colour with the
- NEIGHBOUR's; where two differently-coloured full-bleed cells sit side by side, each can
- slightly tint the other's outermost sample. Same bounded, accepted class as the old
- background-vs-background softness — a faint tint at extreme zoom-out, never a seam and never a
- ghost glyph. Report it only if it reads as more than that.
+ **Expected residual 0a — two adjacent full-bleed slots.** At the worst subpixel phase and mip
+ level 2, a bilinear tap reaches a gutter texel blending THIS slot's edge colour with the
+ NEIGHBOUR's — **up to 25%** of the sampled value. Where two differently-coloured full-bleed
+ cells sit side by side, each can therefore tint the other's outermost sample by that much.
+ Same weight as before this change (it used to be 25% of the neighbour's *background*), so it
+ is the same bounded, accepted class — a faint tint at extreme zoom-out, never a seam and never
+ a ghost glyph. Report it only if it reads as more than that.
+ **Expected residual 0b — a fractional device cell keeps a small dip.** A device cell is
+ `charWidth * dpr`, so at most dprs one or both axes are FRACTIONAL and the cell's outermost
+ texel is only partly covered — a genuine ink/background blend that belongs to the cell and
+ cannot be filled in from outside. The gutter beside it continues the last FULLY covered texel,
+ which brings the boundary dip down from 62.5 points (flat bg gutter, the reported bug) to
+ **12.5 points**; sourcing the partial texel instead would have left 37.5. So: a faint reduced
+ dip may survive on an axis whose device cell extent is fractional, and it should read as a
+ barely-perceptible softening, NOT as the dark grout lattice above. If a dip is clearly visible
+ as a dark line, that is the blocking report, not this residual — note the display's dpr and
+ whether it appears on one axis or both.
**Expected residual 1 — the LOD clamp.** The sampler is forbidden to go deeper than mip level 2,
because that is the deepest level the gutter can keep free of a neighbouring glyph's ink. Past
roughly 25% the filter therefore cannot get any softer, and slight aliasing comes back. That is
diff --git a/src/renderer/glyphgrid/atlas.ts b/src/renderer/glyphgrid/atlas.ts
index 831d76230..7f927e236 100644
--- a/src/renderer/glyphgrid/atlas.ts
+++ b/src/renderer/glyphgrid/atlas.ts
@@ -40,12 +40,14 @@ export interface GlyphRasterizer {
* raster.ts fills it with the slot's own content, and gl-webgl2.ts offsets its uv derivation by it.
*
* WHAT THE GUTTER CARRIES. Not simply background — the slot's own EDGE-EXTENDED content: raster.ts
- * fills it with the slot's background and then replicates the cell's outermost texel row/column
- * outward into it (clamp-to-edge padding). For ordinary text the border texels ARE background, so
- * that is bit-identical to a flat bg fill; for a glyph whose ink reaches the cell edge (blocks, box
- * lines, progress bars) the gutter continues the INK, which is what stops a minified sample at the
- * cell edge from averaging ink with background and drawing a dark seam. See step 3 of `draw` in
- * raster.ts for the device report that forced this.
+ * fills it with the slot's background and then replicates the cell's last FULLY COVERED texel
+ * row/column outward into it (clamp-to-edge padding). For ordinary text those border texels ARE
+ * background, so that is bit-identical to a flat bg fill; for a glyph whose ink reaches the cell
+ * edge (blocks, box lines, progress bars) the gutter continues the INK, which is what stops a
+ * minified sample at the cell edge from averaging ink with background and drawing a dark seam. See
+ * step 3 of `draw` in raster.ts for the device report that forced this and for the coverage table
+ * behind "last fully covered" (a fractional cell's outermost texel is a partial-coverage blend, and
+ * replicating THAT leaves a 37.5-point dip where the last full one leaves 12.5).
*
* WHY 2 — the derivation, since this number is what bounds the usable mip chain. A mip level-n
* texel is the average of an aligned 2^n × 2^n block of level-0 texels. Two slots' CELLS are
@@ -56,16 +58,26 @@ export interface GlyphRasterizer {
* not require: it requires the gutter to hold colours OWNED BY THIS SLOT, which the pitch layout
* guarantees whatever raster.ts writes there — it never required them to be background.
*
- * What the gutter does NOT promise, stated so nobody reads more into it: bilinear filtering WITHIN
- * a level still reaches the adjacent texel, which at level 2 can be a pure-gutter texel blending
- * this slot's edge colour with the neighbour's. Usually that is background against background; two
- * adjacent full-bleed slots make it ink against ink, possibly tinting each other's outermost
- * sample. Either way it is a soft edge between two slots' EDGE colours at heavy zoom-out — never a
- * ghost glyph — and it is the residual the LOD clamp accepts. The promise is that no glyph GEOMETRY
- * is ever drawn outside its cell rect, and it holds only while raster.ts keeps clipping the ink:
- * ink allowed to overhang into the gutter shortens the cell-to-cell separation and invalidates the
- * derivation above. (Copying this slot's own edge texels outward does not — a copy of our own
- * content is not a second slot's ink.)
+ * What the gutter does NOT promise, stated so nobody reads more into it — with the weights, because
+ * "some bleed" and "6% of one colour" are very different reports:
+ *
+ * - Bilinear filtering WITHIN level 2 still reaches the adjacent texel, and the four gutter
+ * columns between two cells (two ours, two theirs) can share one level-2 texel. At the worst
+ * phase a sample taken at our cell edge can therefore carry up to **25% of the NEIGHBOUR's edge
+ * colour**. Before edge extension that was 25% of the neighbour's BACKGROUND; it is now 25% of
+ * whatever its edge holds, which for two adjacent full-bleed slots is its ink. Same weight, more
+ * visible content — a faint tint between block-art cells at heavy zoom-out, never a seam.
+ * - "A PURE-gutter texel" is too generous as a blanket claim, and this half is PRE-EXISTING —
+ * edge extension does not change it, since it is about which texels a tap reaches, not what
+ * they hold. At one pitch alignment in four the FAR level-2 texel of the tap straddles the
+ * gutter and the neighbour's first CELL columns; weighted through the tap, the neighbour's cell
+ * contributes about **6.25%** of the sampled value. Still a tint rather than a ghost glyph, and
+ * it is the honest shape of the residual the LOD clamp accepts.
+ *
+ * The promise is that no glyph GEOMETRY is ever drawn outside its cell rect, and it holds only
+ * while raster.ts keeps clipping the ink: ink allowed to overhang into the gutter shortens the
+ * cell-to-cell separation and invalidates the derivation above. (Copying this slot's own edge
+ * texels outward does not — a copy of our own content is not a second slot's ink.)
*/
export const GUTTER_PX = 2
diff --git a/src/renderer/glyphgrid/gl-webgl2.ts b/src/renderer/glyphgrid/gl-webgl2.ts
index 77f0aec93..0d580015e 100644
--- a/src/renderer/glyphgrid/gl-webgl2.ts
+++ b/src/renderer/glyphgrid/gl-webgl2.ts
@@ -24,12 +24,15 @@ import { plateRectDevice } from './plate'
* still a valid min filter here. (An earlier version of this comment claimed the API offers no way
* to build fewer levels. It does; that sentence was wrong.)
*
- * The residual the clamp accepts is stated in GUTTER_PX's comment: at level 2 a bilinear tap can
- * reach a pure-gutter texel holding a blend of THIS SLOT'S EDGE COLOUR and the NEIGHBOUR'S. For
- * ordinary text both edges are background, so that is the background-vs-background softness it has
- * always been; where two full-bleed slots sit side by side (block art, box-drawing rules) the two
- * edges are ink and can tint each other's outermost sample. Same bounded, accepted class either
- * way — a soft edge at heavy zoom-out, never a ghost glyph.
+ * The residual the clamp accepts is stated with its weights in GUTTER_PX's comment. In short: at
+ * level 2 a bilinear tap reaches a gutter texel blending THIS SLOT'S EDGE COLOUR with the
+ * NEIGHBOUR'S, up to 25% of the sampled value at the worst phase — for ordinary text that is the
+ * background-vs-background softness it has always been, and where two full-bleed slots sit side by
+ * side (block art, box-drawing rules) it is ink against ink instead. And that texel is not always
+ * PURE gutter: at one pitch alignment in four the tap's far level-2 texel straddles the neighbour's
+ * first CELL columns, weighting its cell at roughly 6.25% of the sample. That half is PRE-EXISTING
+ * — it is about which texels a tap reaches, not what they hold, so edge extension neither caused
+ * nor changed it. Both are tints at heavy zoom-out, never a ghost glyph.
*/
const MAX_SAFE_LOD = Math.floor(Math.log2(2 * GUTTER_PX))
diff --git a/src/renderer/glyphgrid/raster.test.ts b/src/renderer/glyphgrid/raster.test.ts
index 78801a0bd..b6e845604 100644
--- a/src/renderer/glyphgrid/raster.test.ts
+++ b/src/renderer/glyphgrid/raster.test.ts
@@ -118,7 +118,12 @@ function stubCanvas(sizePx = 256): {
},
/** Only the 9-argument form, and only with WHOLE-texel destination rects — which is all the
* rasterizer's gutter replication uses. Nearest-neighbour sampling off a SNAPSHOT of the page,
- * which is what the spec guarantees for a self-referencing drawImage. */
+ * which is what the spec guarantees for a self-referencing drawImage.
+ *
+ * `imageSmoothingEnabled` is RECORDED, NOT HONOURED: this model always replicates. So the
+ * pixel assertions below prove WHICH texel is copied where — they do NOT prove that the real
+ * canvas replicates rather than resamples. That claim rests entirely on the flag being off,
+ * which is why it has its own op-level test. */
drawImage(
src: unknown,
sx: number,
@@ -346,7 +351,15 @@ describe('createCanvasRasterizer', () => {
// The first real glyph starts at slot 1 — i.e. past the origin cell. Not even its background
// fill may reach slot 0's pitch rect.
atlas.glyphFor(0x41, false, false, FG, BG)
- expect(stub.ops.some((o) => o.args[0] < PITCH_W && o.args[1] < PITCH_H)).toBe(false)
+ // Which args carry the DESTINATION differs by op: a drawImage records source-then-dest, so the
+ // reach of a replication strip is args[4..5], not args[0..1] (its source is by construction
+ // inside the slot's own cell, and reading that as the destination would pin nothing).
+ const reachesSlot0 = (o: Op): boolean => {
+ const dx = o.kind === 'drawImage' ? o.args[4] : o.args[0]
+ const dy = o.kind === 'drawImage' ? o.args[5] : o.args[1]
+ return dx < PITCH_W && dy < PITCH_H
+ }
+ expect(stub.ops.some(reachesSlot0)).toBe(false)
})
/**
@@ -465,5 +478,105 @@ describe('createCanvasRasterizer', () => {
expect(stub.pixelAt(INK_X + COLS_W + GUTTER_PX - 1, INK_Y - GUTTER_PX)).toBe(BG_CSS)
expect(stub.pixelAt(INK_X - GUTTER_PX, INK_Y + COLS_H + GUTTER_PX - 1)).toBe(FG_CSS)
})
+
+ /**
+ * FRACTIONAL AND SUB-TEXEL CELLS. `device.cell.width` is `charWidth * dpr` and is fractional in
+ * general, so `ceil` being the identity is a property of the 10x20 font above and of nothing
+ * else. Two things have to hold on a fractional axis:
+ *
+ * - the strip DESTINATIONS still tile the gutter frame EXACTLY (the pitch rect minus the whole
+ * texel columns/rows the cell occupies) — no double-covered texel, no missed one, and in
+ * particular a right/bottom gutter that is exactly GUTTER_PX wide rather than
+ * `pitch - cell` wide;
+ * - the strip SOURCE is the last FULLY covered texel, one further in than the cell's outermost
+ * texel — which on a fractional axis is only PARTIALLY covered by the cell. See the
+ * coverage table in raster.ts step 3 for why (replicating the partial texel leaves a
+ * 37.5-point dip; sourcing the last full one drops it to 12.5).
+ */
+ const at = (ink: number, sizes: { cellW: number; cellH: number }) => {
+ const cols = (c: number): number => Math.max(1, Math.ceil(c))
+ return {
+ font: { family: 'monospace', sizePx: 16, ...sizes },
+ ink,
+ colsW: cols(sizes.cellW),
+ colsH: cols(sizes.cellH),
+ pitchW: cols(sizes.cellW) + 2 * GUTTER_PX,
+ pitchH: cols(sizes.cellH) + 2 * GUTTER_PX
+ }
+ }
+ /** Source rects of the four strips, in emit order (left, right, top, bottom). */
+ const sources = (ops: Op[]): number[][] => strips(ops).map((o) => o.args.slice(0, 4))
+ /** Destination rects, same order. */
+ const dests = (ops: Op[]): number[][] => strips(ops).map((o) => o.args.slice(4))
+ const texelsOf = (rects: number[][]): string[] => {
+ const out: string[] = []
+ for (const [rx, ry, rw, rh] of rects)
+ for (let j = ry; j < ry + rh; j++) for (let i = rx; i < rx + rw; i++) out.push(`${i},${j}`)
+ return out
+ }
+
+ it('a FRACTIONAL cell sources the last FULLY COVERED column/row, not the partial edge texel', () => {
+ const stub = stubCanvas()
+ active = stub
+ // 10.5 x 20.5: the cell's outermost texel on each axis is only HALF covered.
+ const c = at(40, { cellW: 10.5, cellH: 20.5 })
+ const r = createCanvasRasterizer(c.font, 256)!
+ stub.ops.length = 0
+ r.draw(0x2588, false, false, c.ink, c.ink, FG, BG)
+
+ // ceil(10.5) - 1 = 10 would be the HALF-covered texel; floor(10.5) - 1 = 9 is the last full
+ // one. The partial texel stays exactly where it is — it is genuine cell content.
+ expect(sources(stub.ops)[1]).toEqual([c.ink + 9, c.ink, 1, c.colsH])
+ expect(sources(stub.ops)[3]).toEqual([c.ink - GUTTER_PX, c.ink + 19, c.pitchW, 1])
+ // The near edges are integral by construction (the ink origin is a whole texel), so their
+ // sources are unchanged.
+ expect(sources(stub.ops)[0]).toEqual([c.ink, c.ink, 1, c.colsH])
+ expect(sources(stub.ops)[2]).toEqual([c.ink - GUTTER_PX, c.ink, c.pitchW, 1])
+ // And the right gutter is exactly GUTTER_PX wide — not `pitch - cellW`.
+ expect(dests(stub.ops)[1]).toEqual([c.ink + c.colsW, c.ink, GUTTER_PX, c.colsH])
+ expect(dests(stub.ops)[3]).toEqual([c.ink - GUTTER_PX, c.ink + c.colsH, c.pitchW, GUTTER_PX])
+ })
+
+ it('a SUB-TEXEL cell sources its one (partial) texel rather than indexing off the page', () => {
+ const stub = stubCanvas()
+ active = stub
+ // 0.5 x 0.5: `floor(cell) - 1` is -1, and the clamp is what keeps the source inside the slot.
+ // There is exactly one texel, half covered, and it is the only thing there is to replicate.
+ const c = at(40, { cellW: 0.5, cellH: 0.5 })
+ const r = createCanvasRasterizer(c.font, 256)!
+ stub.ops.length = 0
+ r.draw(0x2588, false, false, c.ink, c.ink, FG, BG)
+
+ expect(c.colsW).toBe(1)
+ expect(sources(stub.ops)[1]).toEqual([c.ink, c.ink, 1, 1])
+ expect(sources(stub.ops)[3]).toEqual([c.ink - GUTTER_PX, c.ink, c.pitchW, 1])
+ expect(dests(stub.ops)[1]).toEqual([c.ink + 1, c.ink, GUTTER_PX, 1])
+ })
+
+ it.each([
+ ['integral 10x20', { cellW: 10, cellH: 20 }],
+ ['fractional 10.5x20.5', { cellW: 10.5, cellH: 20.5 }],
+ ['barely-fractional 10.01x20.99', { cellW: 10.01, cellH: 20.99 }],
+ ['sub-texel 0.5x0.5', { cellW: 0.5, cellH: 0.5 }]
+ ])('tiles the gutter frame EXACTLY on a %s cell', (_label, sizes) => {
+ const stub = stubCanvas()
+ active = stub
+ const c = at(40, sizes)
+ const r = createCanvasRasterizer(c.font, 256)!
+ stub.ops.length = 0
+ r.draw(0x2588, false, false, c.ink, c.ink, FG, BG)
+
+ const covered = texelsOf(dests(stub.ops))
+ // No texel is written twice — the four strips abut, they do not overlap.
+ expect(new Set(covered).size).toBe(covered.length)
+ // And their union is precisely the pitch rect minus the cell's whole-texel box: every gutter
+ // texel gets edge-extended, and not one texel of the cell is overwritten by a strip.
+ const frame: string[] = []
+ for (let j = c.ink - GUTTER_PX; j < c.ink - GUTTER_PX + c.pitchH; j++)
+ for (let i = c.ink - GUTTER_PX; i < c.ink - GUTTER_PX + c.pitchW; i++)
+ if (i < c.ink || i >= c.ink + c.colsW || j < c.ink || j >= c.ink + c.colsH)
+ frame.push(`${i},${j}`)
+ expect(new Set(covered)).toEqual(new Set(frame))
+ })
})
})
diff --git a/src/renderer/glyphgrid/raster.ts b/src/renderer/glyphgrid/raster.ts
index 68931aa77..404776ce8 100644
--- a/src/renderer/glyphgrid/raster.ts
+++ b/src/renderer/glyphgrid/raster.ts
@@ -182,6 +182,16 @@ export function createCanvasRasterizer(
// pitch" true for a sub-texel cell too.
const colsW = Math.max(1, Math.ceil(font.cellW))
const colsH = Math.max(1, Math.ceil(font.cellH))
+ // The last FULLY COVERED texel column/row of the cell, as an offset from the ink origin — the
+ // SOURCE of the far-edge replication strips (step 3 in `draw` carries the coverage table that
+ // picks it). `floor(cell) - 1` is one formula for both cases: an INTEGRAL 10 gives 9, the cell's
+ // last texel, identical to the `colsW - 1` it replaces; a FRACTIONAL 10.5 also gives 9, stepping
+ // over texel 10 — the half-covered edge texel, whose antialiased ink/background blend is exactly
+ // what must not be smeared across the whole gutter. `max(0, …)` is the sub-texel case
+ // (`cell < 1` → -1): there is no fully covered texel at all, and the slot's single partial one is
+ // the only thing there is to replicate.
+ const lastFullCol = Math.max(0, Math.floor(font.cellW) - 1)
+ const lastFullRow = Math.max(0, Math.floor(font.cellH) - 1)
return {
cellW: font.cellW,
cellH: font.cellH,
@@ -275,39 +285,80 @@ export function createCanvasRasterizer(
// 2D canvas (the source region is read as a snapshot before anything is written), which is
// what lets the top/bottom strips below read a row the side strips have just extended.
//
- // FRACTIONAL CELLS: the cell's outer edge falls inside a texel in general, so the border
- // texel being copied may be a partial-coverage ANTIALIASED blend of ink and background.
- // Replicating the blend is CORRECT — it is still this slot's own edge colour, and it is
- // exactly the colour the sampler would tap just inside the cell.
+ // FRACTIONAL CELLS — why the far-edge strips source `lastFullCol`/`lastFullRow` rather
+ // than the cell's outermost texel. A device cell is `charWidth * dpr` and is fractional in
+ // general, so its outer edge falls INSIDE a texel: that texel is only partially covered by
+ // the cell, and the rasterizer leaves it as an antialiased blend of ink and background
+ // (0.5 ink on a .5 cell). It is genuine cell content and STAYS exactly where it is — the
+ // question is only what the GUTTER beside it should continue.
+ //
+ // Take a full-bleed cell (ink = 1, background = 0) with a .5-fractional width, and read
+ // off the level-2 block that straddles the boundary — four columns: the last full column,
+ // the half-covered edge texel, and the two gutter texels:
+ //
+ // gutter holds block average dip vs solid ink
+ // ─────────────────────── ──────────────────── ───────── ────────────────
+ // background (before) 1, 0.5, 0, 0 37.5% 62.5 pts
+ // the PARTIAL texel 1, 0.5, 0.5, 0.5 62.5% 37.5 pts
+ // the last FULL texel 1, 0.5, 1, 1 87.5% 12.5 pts
+ //
+ // Replicating the partial texel is not wrong — it is still this slot's own edge colour —
+ // but it carries the half-coverage outward and leaves a visibly reduced grout dip on that
+ // axis. Sourcing one texel further in is what a COMPOSED-frame downscale would see: the
+ // neighbouring cell's ink begins mid-texel, so beyond the boundary the colour is solidly
+ // the neighbour's, not a fade to background.
+ //
+ // RESIDUAL, stated so nobody hunts for it: 12.5 points, from the partial texel itself,
+ // which no gutter content can cancel — it belongs to the cell. Only an axis whose device
+ // cell extent is fractional has it at all.
const prevSmoothing = ctx.imageSmoothingEnabled
// A 1-texel source stretched over GUTTER_PX texels must REPLICATE, not resample: with
// smoothing on the copy would fade back towards whatever the gutter held, which is the
// background this whole step exists to get out of the way.
ctx.imageSmoothingEnabled = false
- // ORDER: the two SIDE strips first, over the cell's rows only; then the two full-PITCH-wide
- // ROW strips. By the time the top strip copies row `y`, that row already carries the side
- // strips' texels in the left and right gutters — so each corner of the gutter ends up
- // holding the cell's CORNER texel, which is what a clamp-to-edge pad means. Doing the rows
- // first (and the sides over the full pitch height) would work equally well; what must not
- // happen is both passes covering only the cell's own extent, which leaves the four corner
- // squares as stale background.
- ctx.drawImage(canvas, x, y, 1, colsH, x - GUTTER_PX, y, GUTTER_PX, colsH)
- ctx.drawImage(canvas, x + colsW - 1, y, 1, colsH, x + colsW, y, GUTTER_PX, colsH)
- ctx.drawImage(canvas, x - GUTTER_PX, y, pitchW, 1, x - GUTTER_PX, y - GUTTER_PX, pitchW, GUTTER_PX)
- ctx.drawImage(
- canvas,
- x - GUTTER_PX,
- y + colsH - 1,
- pitchW,
- 1,
- x - GUTTER_PX,
- y + colsH,
- pitchW,
- GUTTER_PX
- )
- // Restored rather than left off: the flag is page-wide state, and the next slot's fills are
- // not this call's business.
- ctx.imageSmoothingEnabled = prevSmoothing
+ try {
+ // ORDER: the two SIDE strips first, over the cell's rows only; then the two full-PITCH-wide
+ // ROW strips. By the time the top strip copies row `y`, that row already carries the side
+ // strips' texels in the left and right gutters — so each corner of the gutter ends up
+ // holding the cell's CORNER texel, which is what a clamp-to-edge pad means. Doing the rows
+ // first (and the sides over the full pitch height) would work equally well; what must not
+ // happen is both passes covering only the cell's own extent, which leaves the four corner
+ // squares as stale background.
+ //
+ // The DESTINATIONS tile the gutter frame exactly — the pitch rect minus the cell's
+ // whole-texel box, no overlap and no gap — on a fractional cell too, because `colsW`/`colsH`
+ // come from `slotPitch`'s own expression. Only the far-edge SOURCES step inward.
+ ctx.drawImage(canvas, x, y, 1, colsH, x - GUTTER_PX, y, GUTTER_PX, colsH)
+ ctx.drawImage(canvas, x + lastFullCol, y, 1, colsH, x + colsW, y, GUTTER_PX, colsH)
+ ctx.drawImage(
+ canvas,
+ x - GUTTER_PX,
+ y,
+ pitchW,
+ 1,
+ x - GUTTER_PX,
+ y - GUTTER_PX,
+ pitchW,
+ GUTTER_PX
+ )
+ ctx.drawImage(
+ canvas,
+ x - GUTTER_PX,
+ y + lastFullRow,
+ pitchW,
+ 1,
+ x - GUTTER_PX,
+ y + colsH,
+ pitchW,
+ GUTTER_PX
+ )
+ } finally {
+ // `finally`, not a trailing assignment: `imageSmoothingEnabled` is PAGE-WIDE state, and a
+ // draw that threw part-way (a context lost mid-repack, say) would otherwise leave every
+ // later slot's fills unsmoothed for the rest of the session — a permanent, invisible change
+ // to a global from a transient failure.
+ ctx.imageSmoothingEnabled = prevSmoothing
+ }
}
}
}