<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grain Cross</title>
<style>
:root{
--ground:#F3EEE2;--card:#E6E3CE;--card2:#EBE8D7;--ink:#1E1F15;--deep:#0F100A;
--lift:#3D4128;--muted:#5A5E3B;--soft:#C9C8A6;--accent:#86914C;
--font:"Geist",system-ui,-apple-system,sans-serif;
}
@font-face{font-family:"Geist";src:url("/fonts-geist/Geist-Regular-latin.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap;}
@font-face{font-family:"Geist";src:url("/fonts-geist/Geist-Medium-latin.woff2") format("woff2");font-weight:500;font-style:normal;font-display:swap;}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--ground);color:var(--ink);font-family:var(--font);-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}
.cover{width:100%;height:100%;object-fit:cover;object-position:center;display:block;pointer-events:none;user-select:none}
.hint{position:fixed;left:50%;bottom:5vh;transform:translateX(-50%);margin:0;font-size:10px;font-weight:500;letter-spacing:.22em;text-transform:uppercase;color:var(--muted);pointer-events:none;z-index:5;white-space:nowrap}
@media (prefers-reduced-motion:reduce){ .hint{display:none} }
html,body{overflow:hidden}
.stage{position:fixed;inset:0;cursor:pointer;background:var(--card2)}
canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
</style>
</head>
<body>
<div class="stage" id="stage" role="button" tabindex="0" aria-label="Cross to the next still">
<canvas id="c"></canvas>
</div>
<p class="hint">Click or tap</p>
<script>
(function(){
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const srcOf = (f) => "/images/webp/" + f;
const files = ["midwinter-window.webp","hotel-corridor.webp","night-desk.webp","sunday-kitchen.webp","night-arcade.webp","autumn-clearing.webp"];
const canvas = document.getElementById("c");
const ctx = canvas.getContext("2d", {alpha:false});
const images = [];
let i = 0, prog = 1, from = 0, to = 0, running = false;
let noise, off, octx;
function fit(){
const dpr = Math.min(1.5, window.devicePixelRatio || 1);
canvas.width = Math.floor(canvas.clientWidth * dpr);
canvas.height = Math.floor(canvas.clientHeight * dpr);
}
function coverDraw(img){
if (!img || !img.width) return;
const cw = canvas.width, ch = canvas.height;
const s = Math.max(cw / img.width, ch / img.height);
const w = img.width * s, h = img.height * s;
ctx.drawImage(img, (cw-w)/2, (ch-h)/2, w, h);
}
function makeNoise(){
const w = canvas.width, h = canvas.height;
const imgd = ctx.createImageData(w, h);
const d = imgd.data;
for (let p=0;p<d.length;p+=4){
const n = Math.random()*255;
d[p]=d[p+1]=d[p+2]=n; d[p+3]=255;
}
return imgd;
}
function render(){
const A = images[from], B = images[to];
if (prog >= 1 || reduce){ coverDraw(images[i]); return; }
coverDraw(B);
if (!noise) return;
const cw = canvas.width, ch = canvas.height;
if (!off || off.width !== cw) { off = document.createElement("canvas"); off.width=cw; off.height=ch; octx = off.getContext("2d"); }
const s = Math.max(cw / A.width, ch / A.height);
const w = A.width * s, h = A.height * s;
octx.clearRect(0,0,cw,ch);
octx.drawImage(A, (cw-w)/2, (ch-h)/2, w, h);
const px = octx.getImageData(0,0,cw,ch);
const thresh = prog * 255;
const nd = noise.data, pd = px.data;
for (let p=0;p<pd.length;p+=4){
if (nd[p] < thresh) pd[p+3]=0;
}
octx.putImageData(px,0,0);
ctx.drawImage(off,0,0);
}
function loadAll(){
return Promise.all(files.map((f) => new Promise((res) => {
const im = new Image();
im.onload = () => res(im);
im.src = srcOf(f);
})));
}
let last = 0;
function tick(now){
if (running){
const dt = Math.min(0.05, (now-last)/1000 || 0.016);
prog = Math.min(1, prog + dt / 1.05);
if (prog >= 1){ running=false; i=to; from=to; }
render();
}
last = now;
requestAnimationFrame(tick);
}
function go(){
if (running) return;
from = i; to = (i+1)%files.length;
if (reduce){ i=to; render(); return; }
noise = makeNoise();
prog = 0; running = true;
}
fit();
loadAll().then((ims) => {
ims.forEach((im)=>images.push(im));
render();
requestAnimationFrame(tick);
});
window.addEventListener("resize", () => { fit(); noise=null; render(); });
const stage=document.getElementById("stage");
stage.addEventListener("click", go);
stage.addEventListener("keydown", (e)=>{ if(e.key==="Enter"||e.key===" ") { e.preventDefault(); go(); }});
})();
</script>
</body>
</html>
Build a single self-contained HTML file (vanilla CSS and JavaScript; GSAP 3.13+ from jsDelivr, plus ScrollTrigger or Flip only if required) for “Grain Cross”.
Film grain dissolves one still into the next, then leaves a clean frame.
Use the Olive & Moss palette: ground #F3EEE2, card #E6E3CE, ink #1E1F15, deep #0F100A, lift #3D4128, muted #5A5E3B, soft #C9C8A6, accent #86914C. Amber #FFA51F is not used as type. Images use object-fit: cover (or equivalent cover mapping in a shader) and must be undistorted at rest. Easing: expo.out / power3.inOut, no bounce or elastic. Respect prefers-reduced-motion. One file.