From f8113f7a94c1feda462f99c0082fd7656a0dd7b4 Mon Sep 17 00:00:00 2001 From: Josh Bairstow Date: Wed, 3 Jun 2026 15:45:59 +1000 Subject: [PATCH] refactor(islands): remove dead offscreen canvas pixel writes from updateField --- src/components/islands/ParticleField.tsx | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/components/islands/ParticleField.tsx b/src/components/islands/ParticleField.tsx index d183574..cc5c8f8 100644 --- a/src/components/islands/ParticleField.tsx +++ b/src/components/islands/ParticleField.tsx @@ -93,10 +93,6 @@ export default function ParticleField() { const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches; const cfg = PARTICLE_CONFIG; - const off = document.createElement("canvas"); - off.width = cfg.fieldOffscreenW; - off.height = cfg.fieldOffscreenH; - const oCtx = off.getContext("2d")!; const fieldCache = new Float32Array(cfg.fieldOffscreenW * cfg.fieldOffscreenH); const P = buildPermutation(); @@ -147,21 +143,12 @@ export default function ParticleField() { const scale = fieldScale * 0.0018; const ox = elapsed * timeConstantX; const oy = elapsed * timeConstantY; - const imgData = oCtx.createImageData(oW, oH); - const d = imgData.data; for (let py = 0; py < oH; py++) { for (let px = 0; px < oW; px++) { const raw = fbm(P, px * scale + ox, py * scale + oy, fieldOctaves); - const v = Math.max(0, Math.min(1, raw * 1.8 + 0.5)); - fieldCache[py * oW + px] = v; - const idx = (py * oW + px) * 4; - d[idx] = Math.round(v * 30 + (1 - v) * 5); - d[idx + 1] = Math.round(v * 110 + (1 - v) * 18); - d[idx + 2] = Math.round(v * 210 + (1 - v) * 55); - d[idx + 3] = 255; + fieldCache[py * oW + px] = Math.max(0, Math.min(1, raw * 1.8 + 0.5)); } } - oCtx.putImageData(imgData, 0, 0); } function draw() {