<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Lab on wesley.deal</title><link>https://staging.rn02.wesley.deal/lab/</link><description>Recent content in Lab on wesley.deal</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 29 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://staging.rn02.wesley.deal/lab/index.xml" rel="self" type="application/rss+xml"/><item><title>Koi Pond Screensaver</title><link>https://staging.rn02.wesley.deal/lab/koi/</link><pubDate>Fri, 29 May 2026 00:00:00 +0000</pubDate><guid>https://staging.rn02.wesley.deal/lab/koi/</guid><description>&lt;!doctype html&gt;&#10;&lt;html lang="en"&gt;&#10;&lt;head&gt;&#10;&lt;meta charset="utf-8"&gt;&#10;&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;&#10;&lt;title&gt;&lt;/title&gt;&#10;&lt;style&gt;&#10; @import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&amp;display=swap");&#10;&#10; html, body {&#10; margin: 0;&#10; width: 100%;&#10; height: 100%;&#10; overflow: hidden;&#10; background: #061923;&#10; }&#10;&#10; canvas {&#10; display: block;&#10; width: 100vw;&#10; height: 100vh;&#10; image-rendering: pixelated;&#10; image-rendering: crisp-edges;&#10; }&#10;&#10; .controls {&#10; position: fixed;&#10; right: 12px;&#10; bottom: 12px;&#10; z-index: 2;&#10; display: grid;&#10; gap: 8px;&#10; min-width: 150px;&#10; padding: 10px 12px;&#10; color: #b8d7cf;&#10; background: rgba(4, 19, 29, .62);&#10; border: 1px solid rgba(111, 178, 169, .22);&#10; box-shadow: 0 6px 0 rgba(0, 0, 0, .18);&#10; font: 13px/1.1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;&#10; opacity: 0;&#10; transform: translateY(4px);&#10; transition: opacity .18s linear, transform .18s linear;&#10; pointer-events: none;&#10; }&#10;&#10; .controls.visible {&#10; opacity: 1;&#10; transform: translateY(0);&#10; pointer-events: auto;&#10; }&#10;&#10; .controls label {&#10; display: flex;&#10; align-items: center;&#10; justify-content: space-between;&#10; gap: 12px;&#10; user-select: none;&#10; }&#10;&#10; .controls input[type="range"] {&#10; width: 78px;&#10; accent-color: #6fb2a9;&#10; }&#10;&#10; .controls input[type="checkbox"] {&#10; accent-color: #6fb2a9;&#10; }&#10;&#10; .controls select {&#10; color: #b8d7cf;&#10; background: rgba(6, 25, 35, .82);&#10; border: 1px solid rgba(111, 178, 169, .24);&#10; font: inherit;&#10; }&#10;&#10; .subcontrols {&#10; display: grid;&#10; gap: 7px;&#10; padding-left: 10px;&#10; border-left: 1px solid rgba(111, 178, 169, .20);&#10; }&#10;&lt;/style&gt;&#10;&lt;/head&gt;&#10;&lt;body&gt;&#10;&lt;canvas id="pond"&gt;&lt;/canvas&gt;&#10;&lt;div id="controls" class="controls" aria-label="screensaver controls"&gt;&#10; &lt;label&gt;auto-feed &lt;input id="autoFeed" type="checkbox" checked&gt;&lt;/label&gt;&#10; &lt;label&gt;clock &lt;input id="clockToggle" type="checkbox"&gt;&lt;/label&gt;&#10; &lt;div class="subcontrols" aria-label="clock options"&gt;&#10; &lt;label&gt;scale &lt;input id="clockScale" type="range" min="0.9" max="2.7" step="0.1" value="1.6"&gt;&lt;/label&gt;&#10; &lt;label&gt;time &lt;select id="clockFormat"&gt;&lt;option value="12"&gt;12h&lt;/option&gt;&lt;option value="24"&gt;24h&lt;/option&gt;&lt;option value="secs"&gt;secs&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&#10; &lt;label&gt;date &lt;input id="clockDate" type="checkbox"&gt;&lt;/label&gt;&#10; &lt;label&gt;movement &lt;input id="clockMovement" type="checkbox" checked&gt;&lt;/label&gt;&#10; &lt;/div&gt;&#10; &lt;label&gt;lily pads &lt;input id="padSlider" type="range" min="0" max="2" step="0.1" value="1"&gt;&lt;/label&gt;&#10; &lt;label&gt;scale &lt;input id="scaleSlider" type="range" min="1" max="10" step="1" value="1"&gt;&lt;/label&gt;&#10; &lt;label&gt;fish &lt;input id="fishSlider" type="range" min="1" max="15" step="1" value="6"&gt;&lt;/label&gt;&#10;&lt;/div&gt;&#10;&lt;script&gt;&#10;(() =&gt; {&#10; "use strict";&#10;&#10; const canvas = document.getElementById("pond");&#10; const controls = document.getElementById("controls");&#10; const autoFeedInput = document.getElementById("autoFeed");&#10; const clockInput = document.getElementById("clockToggle");&#10; const clockScaleInput = document.getElementById("clockScale");&#10; const clockFormatInput = document.getElementById("clockFormat");&#10; const clockDateInput = document.getElementById("clockDate");&#10; const clockMovementInput = document.getElementById("clockMovement");&#10; const padSlider = document.getElementById("padSlider");&#10; const scaleSlider = document.getElementById("scaleSlider");&#10; const fishSlider = document.getElementById("fishSlider");&#10; const pond = document.createElement("canvas");&#10; const pctx = pond.getContext("2d", { alpha: true });&#10; const fishCvs = document.createElement("canvas");&#10; const fctx = fishCvs.getContext("2d", { alpha: true });&#10;&#10; let MAX_UPLOADED_RIPPLES = 64;&#10; const SOFT_RIPPLE_CAP = 384;&#10; const RIPPLE_RETIRE_AGE = 6.0;&#10; const RIPPLE_FADE_SPEED = 1.8;&#10;&#10; const gl = canvas.getContext("webgl", {&#10; alpha: false,&#10; antialias: false,&#10; depth: false,&#10; stencil: false,&#10; preserveDrawingBuffer: false,&#10; premultipliedAlpha: false,&#10; powerPreference: "high-performance"&#10; });&#10; const ctx = gl ? null : canvas.getContext("2d", { alpha: false });&#10; let heightProg, heightU, rippleProg, rippleU, rippleBuf, rippleVerts, glTimes, compProg, compU, heightFBO, heightTex, rippleFBO, rippleTex, sceneTex, overlayTex, bayerTex, palTex, quadBuf;&#10; if (gl) {&#10; MAX_UPLOADED_RIPPLES = 128;&#10;&#10; function makeShader(type, src) {&#10; const s = gl.createShader(type);&#10; gl.shaderSource(s, src);&#10; gl.compileShader(s);&#10; if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) console.error(type === gl.VERTEX_SHADER ? "VS" : "FS", gl.getShaderInfoLog(s));&#10; return s;&#10; }&#10; function makeProgram(vs, fs, attribs) {&#10; const p = gl.createProgram();&#10; gl.attachShader(p, vs);&#10; gl.attachShader(p, fs);&#10; if (attribs) {&#10; for (let i = 0; i &lt; attribs.length; i++) gl.bindAttribLocation(p, i, attribs[i]);&#10; } else {&#10; gl.bindAttribLocation(p, 0, "a");&#10; }&#10; gl.linkProgram(p);&#10; if (!gl.getProgramParameter(p, gl.LINK_STATUS)) console.error("LINK:", gl.getProgramInfoLog(p));&#10; return p;&#10; }&#10; const vsSrc = "attribute vec2 a;void main(){gl_Position=vec4(a,0,1);}";&#10; const sharedVs = makeShader(gl.VERTEX_SHADER, vsSrc);&#10;&#10; // Pass 0: batched additive ripple quads (rasterizes only ripple bounding boxes)&#10; const rippleVsSrc = [&#10; "attribute vec2 aPos;",&#10; "attribute vec4 aW0;",&#10; "attribute vec4 aW1;",&#10; "uniform vec2 uR;",&#10; "varying vec4 vW0,vW1;",&#10; "void main(){",&#10; "vW0=aW0;vW1=aW1;",&#10; "gl_Position=vec4((aPos.x/uR.x)*2.0-1.0,(1.0-aPos.y/uR.y)*2.0-1.0,0.0,1.0);}"&#10; ].join("\n");&#10; const rippleFsSrc = [&#10; "precision highp float;",&#10; "uniform vec2 uR;",&#10; "varying vec4 vW0,vW1;",&#10; "void main(){",&#10; "float x=gl_FragCoord.x,y=uR.y-gl_FragCoord.y;",&#10; "float dx=x-vW0.x,dy=(y-vW0.y)*1.55,d2=dx*dx+dy*dy;",&#10; "if(d2&lt;vW1.x||d2&gt;vW1.y)discard;",&#10; "float d=sqrt(d2);",&#10; "float dr=d-vW0.z;",&#10; "float f=exp(-d*.017-abs(dr)*vW1.z);",&#10; "float v=sin(dr*.82+vW1.w)*f*vW0.w;",&#10; "gl_FragColor=vec4(max(v,0.0)*.25,max(-v,0.0)*.25,0.0,0.0);}"&#10; ].join("\n");&#10; rippleProg = makeProgram(&#10; makeShader(gl.VERTEX_SHADER, rippleVsSrc),&#10; makeShader(gl.FRAGMENT_SHADER, rippleFsSrc),&#10; ["aPos", "aW0", "aW1"]&#10; );&#10; rippleU = { r: gl.getUniformLocation(rippleProg, "uR") };&#10; rippleBuf = gl.createBuffer();&#10; rippleVerts = new Float32Array(MAX_UPLOADED_RIPPLES * 6 * 10);&#10; gl.bindBuffer(gl.ARRAY_BUFFER, rippleBuf);&#10; gl.bufferData(gl.ARRAY_BUFFER, rippleVerts.byteLength, gl.DYNAMIC_DRAW);&#10;&#10; const commonGlsl = [&#10; "float hash(float n){return fract(sin(n)*43758.5453);}",&#10; "float n2d(float x,float y){float ix=floor(x),iy=floor(y);float fx=fract(x),fy=fract(y);",&#10; "fx=fx*fx*(3.0-2.0*fx);fy=fy*fy*(3.0-2.0*fy);",&#10; "float a=hash(ix+iy*57.0),b=hash(ix+1.0+iy*57.0),c=hash(ix+(iy+1.0)*57.0),d=hash(ix+1.0+(iy+1.0)*57.0);",&#10; "return mix(mix(a,b,fx),mix(c,d,fx),fy);}",&#10; "vec2 warp(vec2 p){",&#10; "float a=n2d(p.x*.004+uT[0]*.02,p.y*.004-uT[1]*.02)*2.-1.;",&#10; "float b=n2d(p.x*.006-uT[2]*.018,p.y*.006+uT[3]*.018)*2.-1.;",&#10; "float c=n2d(p.x*.0018+uT[4]*.03,p.y*.0018-uT[5]*.03)*2.-1.;",&#10; "float d=n2d(p.x*.009-uT[5]*.015,p.y*.009+uT[0]*.015)*2.-1.;",&#10; "p+=vec2(a*1.25+d*.55,b*1.25-d*.35);",&#10; "float r=c*.085;",&#10; "float cr=cos(r),sr=sin(r);",&#10; "return mat2(cr,-sr,sr,cr)*p;}"&#10; ];&#10;&#10; // Pass 1: compute bm (16-bit RG), ca (8-bit B), cycle-shade*.42 (8-bit A) ONCE per pixel&#10; const heightFsSrc = [&#10; "precision highp float;",&#10; "uniform vec2 uR;",&#10; "uniform float uT[6];",&#10; ...commonGlsl,&#10; "float micro(float x,float y){",&#10; "float v=n2d(x*.11+uT[0]*.72,y*.11+uT[1]*.54)*.055;",&#10; "v+=n2d(x*.23-uT[2]*1.05,y*.23+uT[3]*.86)*.044;",&#10; "v+=n2d(x*.43+uT[4]*1.65,y*.43-uT[5]*1.28)*.036;",&#10; "v+=n2d(x*.74-uT[1]*2.15,y*.74+uT[2]*1.72)*.030;",&#10; "v+=sin(x*.37+y*.19+uT[3]*2.4)*.014;",&#10; "v+=sin(x*.52-y*.31-uT[4]*2.0)*.010;return v;}",&#10; "float bgv(float x,float y){",&#10; "float n1=n2d(x*.012+uT[0]*.03,y*.012-uT[1]*.03)*2.-1.;",&#10; "float n2=n2d(x*.021-uT[2]*.02,y*.021+uT[3]*.02)*2.-1.;",&#10; "float n3=n2d(x*.034+uT[4]*.015,y*.034-uT[5]*.015)*2.-1.;",&#10; "float n4=n2d(x*.071+uT[0]*.012,y*.071-uT[1]*.012)*2.-1.;",&#10; "float n5=n2d(x*.113-uT[2]*.010,y*.113+uT[3]*.010)*2.-1.;",&#10; "float current=sin(x*.011+y*.007+uT[0]*.24+n1*.95);",&#10; "current+=sin(x*.006-y*.010-uT[1]*.20+n2*.85)*.85;",&#10; "float v=current*.19;",&#10; "v+=sin(x*.027+y*.018+uT[2]*.62+n1*.65)*.095;",&#10; "v+=sin(x*.041-y*.026-uT[3]*.54+n2*.58)*.075;",&#10; "v+=sin(x*.073+y*.034+uT[4]*.46+n3*.48)*.052;",&#10; "v+=sin(x*.128-y*.061-uT[5]*.38+n4*.70)*.044;",&#10; "v+=sin(x*.205+y*.103+uT[0]*.88+n5*.55)*.032;",&#10; "float lane=sin((x+y*1.65)*.030+uT[1]*.34+n3*1.15);",&#10; "lane+=sin((x*1.55-y*.80)*.023-uT[2]*.30+n1*.85)*.72;",&#10; "v+=smoothstep(.48,.92,lane)*.13;",&#10; "v-=smoothstep(.56,.96,-lane)*.11;",&#10; "return v;}",&#10; "vec2 pack16(float v){",&#10; "float c=floor(clamp(v,0.0,1.0)*65535.0+0.5);",&#10; "float hi=floor(c/256.0);",&#10; "return vec2(hi,c-hi*256.0)/255.0;}",&#10; "void main(){",&#10; "vec2 c=gl_FragCoord.xy;float x=c.x,y=uR.y-c.y;",&#10; "vec2 p=warp(vec2(x,y));",&#10; "float md=micro(p.x,p.y);",&#10; "float bm=bgv(p.x,p.y)+md*.82;",&#10; "float cycle=sin(uT[0]*.20+p.x*.018+p.y*.012)*.18+sin(uT[1]*.14-p.x*.009+p.y*.021)*.13;",&#10; "float ca=sin((p.x+p.y*1.65)*.19+uT[3]*1.35+n2d(p.x*.020,p.y*.020)*2.7);",&#10; "ca+=sin((p.x*1.80-p.y*.72)*.135-uT[4]*1.05+n2d(p.x*.033+7.0,p.y*.033)*1.9)*.72;",&#10; "float shade=smoothstep(.38,.92,-ca+md*2.6)*.18;",&#10; "gl_FragColor=vec4(pack16(bm*.25+.5),clamp(ca/3.6+.5,0.0,1.0),clamp(cycle-shade*.42+.5,0.0,1.0));}"&#10; ].join("\n");&#10;&#10; heightProg = makeProgram(sharedVs, makeShader(gl.FRAGMENT_SHADER, heightFsSrc));&#10; gl.useProgram(heightProg);&#10; quadBuf = gl.createBuffer();&#10; gl.bindBuffer(gl.ARRAY_BUFFER, quadBuf);&#10; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);&#10; gl.enableVertexAttribArray(0);&#10; gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);&#10; heightU = {&#10; r: gl.getUniformLocation(heightProg, "uR"),&#10; t: gl.getUniformLocation(heightProg, "uT")&#10; };&#10; glTimes = new Float32Array(6);&#10;&#10; // Pass 2: shade water + distort fish + composite overlay directly to screen&#10; const compFsSrc = [&#10; "precision highp float;",&#10; "uniform sampler2D uHeight;",&#10; "uniform sampler2D uScene;",&#10; "uniform sampler2D uOverlay;",&#10; "uniform sampler2D uBayer;",&#10; "uniform sampler2D uPal;",&#10; "uniform sampler2D uRipple;",&#10; "uniform vec2 uR;",&#10; "uniform float uT[6];",&#10; "uniform vec3 uP0,uP6,uP7,uF;",&#10; ...commonGlsl,&#10; "float unpack16(vec2 p){return (p.x*65280.0+p.y*255.0)/65535.0;}",&#10; "float decBm(vec2 p){return (unpack16(p)-.5)*4.0;}",&#10; "float decRp(vec2 r){return (r.x-r.y)*4.0;}",&#10; "void main(){",&#10; "vec2 c=gl_FragCoord.xy;",&#10; "vec2 uv=c/uR;",&#10; "vec4 ov=texture2D(uOverlay,vec2(uv.x,1.0-uv.y));",&#10; "if(ov.a&gt;=0.999){gl_FragColor=vec4(ov.rgb,1.0);return;}",&#10; "float x=c.x,y=uR.y-c.y;",&#10; "vec2 px1=1.0/uR;",&#10; "vec4 h0=texture2D(uHeight,uv);",&#10; "vec2 uvR2=vec2(uv.x+2.0*px1.x,uv.y);",&#10; "vec2 uvD2=vec2(uv.x,uv.y-2.0*px1.y);",&#10; "vec4 hR2=texture2D(uHeight,uvR2);",&#10; "vec4 hD2=texture2D(uHeight,uvD2);",&#10; "float bm=decBm(h0.rg);",&#10; "float rp=decRp(texture2D(uRipple,uv).rg);",&#10; "float rpR1=decRp(texture2D(uRipple,vec2(uv.x+px1.x,uv.y)).rg);",&#10; "float rpD1=decRp(texture2D(uRipple,vec2(uv.x,uv.y-px1.y)).rg);",&#10; "float h=bm+rp*.48;",&#10; "float hR=decBm(hR2.rg)+rpR1*.48;",&#10; "float hU=decBm(hD2.rg)+rpD1*.48;",&#10; "float sx=hR-h,sy=hU-h;",&#10; "float gx=floor(x),gy=floor(y);",&#10; "float d=texture2D(uBayer,(vec2(gx,gy)+.5)*.25).r-.5;",&#10; "float ca=(h0.b-.5)*3.6;",&#10; "float cycShade=h0.a-.5;",&#10; "float slope=abs(sx)+abs(sy);",&#10; "float sparkle=0.0;",&#10; "float caRp=ca+rp*.20;",&#10; "if(caRp&gt;.82&amp;&amp;slope&gt;.012){",&#10; "vec2 p=warp(vec2(x,y));",&#10; "float sparse=smoothstep(.26,.96,n2d(p.x*.10-uT[5]*.30,p.y*.10+uT[2]*.30));",&#10; "sparkle=smoothstep(.82,1.78,caRp)*sparse*smoothstep(.012,.095,slope);}",&#10; "float ed=min(min(x,uR.x-x),min(y,uR.y-y));",&#10; "float edge=1.0-smoothstep(0.0,34.0,ed);",&#10; "float deep=smoothstep(0.0,uR.y,y)*.12+edge*.34;",&#10; "float bright=smoothstep(.50,.96,sparkle);",&#10; "float idx=floor((h+1.20+d*.22+cycShade+sparkle*.62+bright*.46-deep*.70)*1.76);",&#10; "if(sx-sy&gt;.44)idx+=2.;if(sx+sy&lt;-.56)idx-=1.;",&#10; "idx+=bright*smoothstep(.03,.40,d)*.62;",&#10; "idx=clamp(idx,0.,7.);",&#10; "vec3 w=texture2D(uPal,vec2((floor(idx)+.5)/8.0,.5)).rgb;",&#10; "float mx=mod(x,4.),my=mod(y,4.);",&#10; "if(my&lt;1.){",&#10; "float gs=sx*1.55-sy*.85+h*.18+sparkle*.35;",&#10; "if(gs&gt;.72&amp;&amp;mx&lt;(gs&gt;1.08?5.:3.))w=gs&gt;1.26?uP7:(gs&gt;1.05?uF:uP6);",&#10; "else if(gs&lt;-.92&amp;&amp;mx&lt;4.)w=uP0;}",&#10; "vec2 uvL2=vec2(uv.x-2.0*px1.x,uv.y);",&#10; "vec2 uvU2=vec2(uv.x,uv.y+2.0*px1.y);",&#10; "float hdL=clamp(decBm(texture2D(uHeight,uvL2).rg)+decRp(texture2D(uRipple,uvL2).rg)*.48,0.0,1.0);",&#10; "float hdR=clamp(decBm(hR2.rg)+decRp(texture2D(uRipple,uvR2).rg)*.48,0.0,1.0);",&#10; "float hdU=clamp(decBm(texture2D(uHeight,uvU2).rg)+decRp(texture2D(uRipple,uvU2).rg)*.48,0.0,1.0);",&#10; "float hdD=clamp(decBm(hD2.rg)+decRp(texture2D(uRipple,uvD2).rg)*.48,0.0,1.0);",&#10; "vec2 distort=vec2((hdL-hdR)*5.0,(hdU-hdD)*5.0);",&#10; "vec2 suv=clamp(uv+distort/uR,0.0,1.0);",&#10; "suv.y=1.0-suv.y;",&#10; "vec4 s=texture2D(uScene,suv);",&#10; "vec3 col=mix(w,s.rgb,s.a);",&#10; "col=mix(col,ov.rgb,ov.a);",&#10; "gl_FragColor=vec4(col,1.0);}"&#10; ].join("\n");&#10;&#10; compProg = makeProgram(sharedVs, makeShader(gl.FRAGMENT_SHADER, compFsSrc));&#10; gl.useProgram(compProg);&#10; compU = {&#10; height: gl.getUniformLocation(compProg, "uHeight"),&#10; scene: gl.getUniformLocation(compProg, "uScene"),&#10; overlay: gl.getUniformLocation(compProg, "uOverlay"),&#10; bayer: gl.getUniformLocation(compProg, "uBayer"),&#10; pal: gl.getUniformLocation(compProg, "uPal"),&#10; ripple: gl.getUniformLocation(compProg, "uRipple"),&#10; r: gl.getUniformLocation(compProg, "uR"),&#10; t: gl.getUniformLocation(compProg, "uT"),&#10; p0: gl.getUniformLocation(compProg, "uP0"),&#10; p6: gl.getUniformLocation(compProg, "uP6"),&#10; p7: gl.getUniformLocation(compProg, "uP7"),&#10; f: gl.getUniformLocation(compProg, "uF")&#10; };&#10; gl.uniform1i(compU.height, 0);&#10; gl.uniform1i(compU.scene, 1);&#10; gl.uniform1i(compU.overlay, 2);&#10; gl.uniform1i(compU.bayer, 3);&#10; gl.uniform1i(compU.pal, 4);&#10; gl.uniform1i(compU.ripple, 5);&#10;&#10; function makeNearestTex(wrap) {&#10; const tex = gl.createTexture();&#10; gl.bindTexture(gl.TEXTURE_2D, tex);&#10; gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);&#10; gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);&#10; gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);&#10; gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);&#10; return tex;&#10; }&#10;&#10; heightTex = makeNearestTex(gl.CLAMP_TO_EDGE);&#10; rippleTex = makeNearestTex(gl.CLAMP_TO_EDGE);&#10; sceneTex = makeNearestTex(gl.CLAMP_TO_EDGE);&#10; overlayTex = makeNearestTex(gl.CLAMP_TO_EDGE);&#10; bayerTex = makeNearestTex(gl.REPEAT);&#10; const bayerVals = [0,.5,.13,.63,.75,.25,.88,.38,.19,.69,.06,.56,.94,.44,.81,.31];&#10; const bayerData = new Uint8Array(16 * 4);&#10; for (let i = 0; i &lt; 16; i++) {&#10; const v = Math.round(bayerVals[i] * 255);&#10; bayerData[i * 4] = v; bayerData[i * 4 + 1] = v; bayerData[i * 4 + 2] = v; bayerData[i * 4 + 3] = 255;&#10; }&#10; gl.bindTexture(gl.TEXTURE_2D, bayerTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 4, 4, 0, gl.RGBA, gl.UNSIGNED_BYTE, bayerData);&#10;&#10; palTex = makeNearestTex(gl.CLAMP_TO_EDGE);&#10; heightFBO = null;&#10; rippleFBO = null;&#10; }&#10;&#10; function hexRGB(hex) {&#10; const v = parseInt(hex.slice(1), 16);&#10; return [((v &gt;&gt; 16) &amp; 255) / 255, ((v &gt;&gt; 8) &amp; 255) / 255, (v &amp; 255) / 255];&#10; }&#10;&#10; const PAL = {&#10; water: ["#061923", "#08212e", "#0a2b3a", "#0f3c4c", "#165467", "#247076", "#5fa09b", "#9fd0c6"],&#10; foam: "#d4efe6",&#10; dark: "#04131d",&#10; rim: "#173a2e",&#10; leaf0: "#1b4730",&#10; leaf1: "#276239",&#10; leaf2: "#4d7f39",&#10; leaf3: "#8aa45b",&#10; leafBlue: "#344e82",&#10; flower: "#e6a7b1",&#10; flower2: "#ffe0c0",&#10; white: "#f6ead8",&#10; pearl: "#ddd7e5",&#10; cream: "#e5c483",&#10; orange: "#dd6b2b",&#10; orange2: "#b74320",&#10; red: "#8f2823",&#10; black: "#191822",&#10; gold: "#c9a84c",&#10; silver: "#b0b8c0",&#10; charcoal: "#3a3540",&#10; pellet: "#b98237",&#10; pelletHi: "#e0b15d"&#10; };&#10;&#10; const BASE_W = 320;&#10; const BASE_H = 180;&#10; let W = BASE_W;&#10; let H = BASE_H;&#10; let scale = 4;&#10; let t = 0;&#10; let last = performance.now();&#10; let nextFeed = 0;&#10; let targetFish = 5;&#10; let nextSchool = 0;&#10; let schoolUntil = 0;&#10; let schoolTarget = null;&#10; let schoolTargetClock = 0;&#10; let feedBatch = 0;&#10; let controlsTimer = 0;&#10; let clockSpot = null;&#10; let clockDragging = false;&#10;&#10; const fish = [];&#10; const fishDraw = [];&#10; const pads = [];&#10; const waves = [];&#10; const pellets = [];&#10; const pops = [];&#10; const settings = {&#10; autoFeed: true,&#10; clock: false,&#10; clockScale: 1.6,&#10; clockFormat: "12",&#10; clockDate: false,&#10; clockMovement: true,&#10; padScale: 1,&#10; scaleOverride: 0,&#10; fishCap: 6,&#10; clockX: null,&#10; clockY: null&#10; };&#10;&#10; const rand = (a, b) =&gt; a + Math.random() * (b - a);&#10; const clamp = (n, a, b) =&gt; Math.max(a, Math.min(b, n));&#10;&#10; function valueNoise(x, y) {&#10; const ix = Math.floor(x), iy = Math.floor(y);&#10; const fx = x - ix, fy = y - iy;&#10; const sx = fx * fx * (3 - 2 * fx), sy = fy * fy * (3 - 2 * fy);&#10; const hash = (a, b) =&gt; { const n = (a | 0) * 1597 + (b | 0) * 51749; return ((n &lt;&lt; 13) ^ n) &amp; 0x7fffffff; };&#10; const lerp = (a, b, t) =&gt; a + (b - a) * t;&#10; const n00 = (hash(ix, iy) &amp; 0xffff) / 0xffff;&#10; const n10 = (hash(ix + 1, iy) &amp; 0xffff) / 0xffff;&#10; const n01 = (hash(ix, iy + 1) &amp; 0xffff) / 0xffff;&#10; const n11 = (hash(ix + 1, iy + 1) &amp; 0xffff) / 0xffff;&#10; return lerp(lerp(n00, n10, sx), lerp(n01, n11, sx), sy);&#10; }&#10;&#10; function fbm(x, y, octaves) {&#10; let v = 0, a = 0.5, f = 1;&#10; for (let i = 0; i &lt; octaves; i++) { v += a * valueNoise(x * f, y * f); a *= 0.5; f *= 2.1; }&#10; return v;&#10; }&#10;&#10; function fishBodyWidth(u) {&#10; if (u &lt; FISH_PROFILE_U[0] || u &gt; FISH_PROFILE_U[FISH_PROFILE_U.length - 1]) return 0;&#10; for (let i = 0; i &lt; FISH_PROFILE_U.length - 1; i++) {&#10; if (u &lt;= FISH_PROFILE_U[i + 1]) {&#10; const t = (u - FISH_PROFILE_U[i]) / (FISH_PROFILE_U[i + 1] - FISH_PROFILE_U[i]);&#10; return FISH_PROFILE_W[i] + (FISH_PROFILE_W[i + 1] - FISH_PROFILE_W[i]) * t;&#10; }&#10; }&#10; return 0;&#10; }&#10;&#10; function hexToRGB(hex) {&#10; const v = parseInt(hex.slice(1), 16);&#10; return [(v &gt;&gt; 16) &amp; 255, (v &gt;&gt; 8) &amp; 255, v &amp; 255];&#10; }&#10;&#10; function parseColor(c) {&#10; if (c.startsWith("#")) return hexToRGB(c);&#10; const m = c.match(/(\d+)/g);&#10; return m ? [+m[0], +m[1], +m[2]] : [0, 0, 0];&#10; }&#10;&#10; const BAYER_4X4 = [0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];&#10; const BEZIER_T2 = [1/64, 4/64, 9/64, 16/64, 25/64, 36/64, 49/64, 1];&#10; const BEZIER_2T1T = [14/64, 24/64, 30/64, 32/64, 30/64, 24/64, 14/64, 0];&#10;&#10; function generatePadTexture(r, veins) {&#10; const tw = Math.max(8, Math.round(r * 2)), th = tw;&#10; const c = document.createElement("canvas");&#10; c.width = tw; c.height = th;&#10; const tc = c.getContext("2d");&#10; const img = tc.createImageData(tw, th);&#10; const d = img.data;&#10; const pal = [parseColor(PAL.leaf0), parseColor(PAL.leaf1), parseColor(PAL.leaf2), parseColor(PAL.leaf3)];&#10; const rim = parseColor(PAL.rim);&#10; const seed = Math.random() * 999;&#10; const seed2 = seed + 137;&#10; const s1 = rand(1.8, 3.2), s2 = rand(1.4, 2.8);&#10; const t1 = rand(0.32, 0.46), t2 = rand(0.38, 0.52);&#10; const invTw2 = 2 / tw;&#10; const vCount = veins.length;&#10; const vEx = new Float64Array(vCount);&#10; const vEy = new Float64Array(vCount);&#10; const vCxBase = new Float64Array(vCount);&#10; const vCyBase = new Float64Array(vCount);&#10; for (let vi = 0; vi &lt; vCount; vi++) {&#10; const vein = veins[vi];&#10; vEx[vi] = Math.cos(vein.angle) * vein.len;&#10; vEy[vi] = Math.sin(vein.angle) * vein.len;&#10; const ca = vein.angle + vein.curve + Math.PI * 0.5;&#10; vCxBase[vi] = Math.cos(ca) * 0.15;&#10; vCyBase[vi] = Math.sin(ca) * 0.15;&#10; }&#10; for (let py = 0; py &lt; th; py++) {&#10; const v = py * invTw2 - 1;&#10; const v2 = v * v;&#10; const bRow = (py &amp; 3) * 4;&#10; const rowOff = py * tw * 4;&#10; for (let px = 0; px &lt; tw; px++) {&#10; const u = px * invTw2 - 1;&#10; const dist2 = u * u + v2;&#10; if (dist2 &gt; 1.1025) continue;&#10; const dist = Math.sqrt(dist2);&#10; const n1 = fbm(u * s1 + seed, v * s1 + seed, 4);&#10; const n2 = fbm(u * s2 + seed2, v * s2 * 1.15 + seed2, 3);&#10; let cr = pal[1][0], cg = pal[1][1], cb = pal[1][2];&#10; if (n1 &gt; t1) {&#10; const t = clamp((n1 - t1) * 1.8, 0, 1);&#10; const sc = n2 &gt; 0.45 ? pal[3] : pal[2];&#10; cr += (sc[0] - cr) * t;&#10; cg += (sc[1] - cg) * t;&#10; cb += (sc[2] - cb) * t;&#10; }&#10; if (n2 &gt; t2) {&#10; const t = clamp((n2 - t2) * 1.5, 0, 1);&#10; cr += (pal[0][0] - cr) * t;&#10; cg += (pal[0][1] - cg) * t;&#10; cb += (pal[0][2] - cb) * t;&#10; }&#10; const veinW = 0.055 + 0.035 * (1 - dist);&#10; const veinW2 = veinW * veinW;&#10; for (let vi = 0; vi &lt; vCount; vi++) {&#10; const ex = vEx[vi], ey = vEy[vi];&#10; const cx2 = vCxBase[vi] * dist, cy2 = vCyBase[vi] * dist;&#10; let minD = Infinity;&#10; let lastBx = 0, lastBy = 0;&#10; for (let s = 0; s &lt; 8; s++) {&#10; const t2s = BEZIER_T2[s], t21 = BEZIER_2T1T[s];&#10; const bx = t2s * ex + t21 * cx2;&#10; const by = t2s * ey + t21 * cy2;&#10; const vx = bx - lastBx, vy = by - lastBy;&#10; const wx = u - lastBx, wy = v - lastBy;&#10; const segLen2 = vx * vx + vy * vy;&#10; const h = segLen2 &gt; 0 ? clamp((wx * vx + wy * vy) / segLen2, 0, 1) : 0;&#10; const ddx = u - (lastBx + vx * h), ddy = v - (lastBy + vy * h);&#10; const dd = ddx * ddx + ddy * ddy;&#10; if (dd &lt; minD) minD = dd;&#10; lastBx = bx; lastBy = by;&#10; }&#10; if (minD &lt; veinW2) {&#10; const blend = Math.pow(clamp(1 - Math.sqrt(minD) / veinW, 0, 1), 1.45) * 0.86;&#10; cr += (rim[0] - cr) * blend;&#10; cg += (rim[1] - cg) * blend;&#10; cb += (rim[2] - cb) * blend;&#10; }&#10; }&#10; const dith40 = (BAYER_4X4[bRow + (px &amp; 3)] / 16 - 0.5) * 40;&#10; let best = 0, bestD = Infinity;&#10; for (let i = 0; i &lt; 4; i++) {&#10; const dr = cr - pal[i][0] + dith40;&#10; const dg = cg - pal[i][1] + dith40;&#10; const db = cb - pal[i][2] + dith40;&#10; const dd = dr * dr + dg * dg + db * db;&#10; if (dd &lt; bestD) { bestD = dd; best = i; }&#10; }&#10; const pc = pal[best];&#10; const edgeFade = clamp(1 - (dist - 0.9) * 5, 0, 1);&#10; const idx = rowOff + px * 4;&#10; d[idx] = pc[0]; d[idx + 1] = pc[1]; d[idx + 2] = pc[2]; d[idx + 3] = Math.round(edgeFade * 255);&#10; }&#10; }&#10; tc.putImageData(img, 0, 0);&#10; return c;&#10; }&#10;&#10; const KOI_COLS_U = Float32Array.from({ length: 32 }, (_, c) =&gt; (c * 2) / 64 * 1.02 - 0.50);&#10;&#10; function generateKoiTexture(scheme) {&#10; const tw = 64, th = 32, res = 2;&#10; const base = parseColor(scheme.base);&#10; const mid = parseColor(scheme.mid);&#10; const spot = parseColor(scheme.spot);&#10; const spot2 = parseColor(scheme.spot2);&#10; const pal = [base, mid, spot, spot2,&#10; [(base[0]+mid[0])&gt;&gt;1,(base[1]+mid[1])&gt;&gt;1,(base[2]+mid[2])&gt;&gt;1],&#10; [(spot[0]+spot2[0])&gt;&gt;1,(spot[1]+spot2[1])&gt;&gt;1,(spot[2]+spot2[2])&gt;&gt;1]&#10; ];&#10; const palCss = pal.map(p =&gt; `rgb(${p[0]},${p[1]},${p[2]})`);&#10; const seed = Math.random() * 999;&#10; const seed2 = seed + 137;&#10; const seed3 = seed + 293;&#10; const s1 = rand(2.4, 4.2), s2 = rand(1.8, 3.5), s3 = rand(3.0, 5.5);&#10; const t1 = rand(0.28, 0.42), t2 = rand(0.32, 0.48);&#10; // Group vertical runs per column for each palette color (100% pixel-identical to 2x2 fillRects)&#10; const runBuckets = Array.from({ length: 6 }, () =&gt; []);&#10; for (let col = 0; col &lt; 32; col++) {&#10; const tx = col * res;&#10; const bodyU = KOI_COLS_U[col];&#10; const maxV = fishBodyWidth(bodyU);&#10; if (maxV &lt;= 0) continue;&#10; const u = tx / tw;&#10; let curColor = -1, runV0 = 0, runV1 = 0;&#10; for (let ty = 0; ty &lt; th; ty += res) {&#10; const v = (ty / th - 0.5) * 2;&#10; if (Math.abs(v) &gt; maxV) {&#10; if (curColor &gt;= 0) { runBuckets[curColor].push(col, runV0, runV1); curColor = -1; }&#10; continue;&#10; }&#10; const n1 = fbm(u * s1 + seed, v * s1 * 0.85 + seed, 4);&#10; const n2 = fbm(u * s2 + seed2, v * s2 * 1.1 + seed2, 3);&#10; const n3 = fbm(u * s3 + seed3, v * s3 * 0.9 + seed3, 3);&#10; const edgeFade = clamp(1 - Math.abs(v) * 0.5, 0, 1);&#10; let r = base[0], g = base[1], b = base[2];&#10; if (n1 &gt; t1) {&#10; const t = clamp((n1 - t1) * 2.2, 0, 1) * edgeFade;&#10; const sc = n3 &gt; 0.45 ? spot2 : spot;&#10; r += (sc[0] - r) * t;&#10; g += (sc[1] - g) * t;&#10; b += (sc[2] - b) * t;&#10; }&#10; if (n2 &gt; t2) {&#10; const t = clamp((n2 - t2) * 2.0, 0, 1) * edgeFade;&#10; r += (mid[0] - r) * t;&#10; g += (mid[1] - g) * t;&#10; b += (mid[2] - b) * t;&#10; }&#10; const dith60 = (BAYER_4X4[(ty &amp; 3) * 4 + (tx &amp; 3)] / 16 - 0.5) * 60;&#10; let best = 0, bestD = Infinity;&#10; for (let i = 0; i &lt; 6; i++) {&#10; const dr = r - pal[i][0] + dith60;&#10; const dg = g - pal[i][1] + dith60;&#10; const db = b - pal[i][2] + dith60;&#10; const dd = dr * dr + dg * dg + db * db;&#10; if (dd &lt; bestD) { bestD = dd; best = i; }&#10; }&#10; if (best === curColor) {&#10; runV1 = v;&#10; } else {&#10; if (curColor &gt;= 0) runBuckets[curColor].push(col, runV0, runV1);&#10; curColor = best;&#10; runV0 = v;&#10; runV1 = v;&#10; }&#10; }&#10; if (curColor &gt;= 0) runBuckets[curColor].push(col, runV0, runV1);&#10; }&#10; const groups = [];&#10; for (let i = 0; i &lt; 6; i++) {&#10; if (runBuckets[i].length &gt; 0) groups.push({ color: palCss[i], runs: runBuckets[i] });&#10; }&#10; return { _runGroups: groups };&#10; }&#10;&#10; function pointerToPond(event) {&#10; const rect = canvas.getBoundingClientRect();&#10; return {&#10; x: (event.clientX - rect.left) / scale,&#10; y: (event.clientY - rect.top) / scale&#10; };&#10; }&#10;&#10; function readBoolParam(params, key, fallback) {&#10; if (!params.has(key)) return fallback;&#10; return params.get(key) === "1";&#10; }&#10;&#10; function readNumberParam(params, key, fallback, min, max) {&#10; if (!params.has(key)) return fallback;&#10; const value = Number(params.get(key));&#10; return Number.isFinite(value) ? clamp(value, min, max) : fallback;&#10; }&#10;&#10; function loadSettingsFromUrl() {&#10; const params = new URLSearchParams(location.search);&#10; settings.autoFeed = readBoolParam(params, "autoFeed", settings.autoFeed);&#10; settings.clock = readBoolParam(params, "clock", settings.clock);&#10; settings.clockScale = readNumberParam(params, "clockScale", settings.clockScale, 0.9, 2.7);&#10; if (params.has("format")) {&#10; const format = params.get("format");&#10; if (format === "12" || format === "24" || format === "secs") settings.clockFormat = format;&#10; } else if (readBoolParam(params, "seconds", false)) {&#10; settings.clockFormat = "secs";&#10; } else if (readBoolParam(params, "h24", false)) {&#10; settings.clockFormat = "24";&#10; }&#10; settings.clockDate = readBoolParam(params, "date", settings.clockDate);&#10; settings.clockMovement = readBoolParam(params, "movement", settings.clockMovement);&#10; settings.padScale = readNumberParam(params, "pads", settings.padScale, 0, 2);&#10; settings.scaleOverride = readNumberParam(params, "scale", settings.scaleOverride, 0, 10);&#10; settings.fishCap = readNumberParam(params, "fish", settings.fishCap, 1, 15);&#10; settings.clockX = readNumberParam(params, "clockX", settings.clockX, 0, 9999);&#10; settings.clockY = readNumberParam(params, "clockY", settings.clockY, 0, 9999);&#10;&#10; autoFeedInput.checked = settings.autoFeed;&#10; clockInput.checked = settings.clock;&#10; clockScaleInput.value = String(settings.clockScale);&#10; clockFormatInput.value = settings.clockFormat;&#10; clockDateInput.checked = settings.clockDate;&#10; clockMovementInput.checked = settings.clockMovement;&#10; padSlider.value = String(settings.padScale);&#10; scaleSlider.value = String(settings.scaleOverride === 0 ? 1 : settings.scaleOverride);&#10; fishSlider.value = String(settings.fishCap);&#10; }&#10;&#10; function writeSettingsToUrl() {&#10; const params = new URLSearchParams();&#10; if (!settings.autoFeed) params.set("autoFeed", "0");&#10; if (settings.clock) params.set("clock", "1");&#10; if (settings.clockScale !== 1.6) params.set("clockScale", settings.clockScale.toFixed(1));&#10; if (settings.clockFormat !== "12") params.set("format", settings.clockFormat);&#10; if (settings.clockDate) params.set("date", "1");&#10; if (!settings.clockMovement) params.set("movement", "0");&#10; if (settings.padScale !== 1) params.set("pads", settings.padScale.toFixed(1));&#10; if (settings.scaleOverride) params.set("scale", String(settings.scaleOverride));&#10; if (settings.fishCap !== 6) params.set("fish", String(settings.fishCap));&#10; if (settings.clockX !== null) params.set("clockX", Math.round(settings.clockX));&#10; if (settings.clockY !== null) params.set("clockY", Math.round(settings.clockY));&#10; const query = params.toString();&#10; history.replaceState(null, "", `${location.pathname}${query ? `?${query}` : ""}${location.hash}`);&#10; }&#10;&#10; function mixHex(a, b, t) {&#10; const av = parseInt(a.slice(1), 16);&#10; const bv = parseInt(b.slice(1), 16);&#10; const ar = av &gt;&gt; 16;&#10; const ag = av &gt;&gt; 8 &amp; 255;&#10; const ab = av &amp; 255;&#10; const br = bv &gt;&gt; 16;&#10; const bg = bv &gt;&gt; 8 &amp; 255;&#10; const bb = bv &amp; 255;&#10; const r = Math.round(ar + (br - ar) * t);&#10; const g = Math.round(ag + (bg - ag) * t);&#10; const bl = Math.round(ab + (bb - ab) * t);&#10; return `rgb(${r},${g},${bl})`;&#10; }&#10;&#10; function smoothstep(e0, e1, x) {&#10; const u = clamp((x - e0) / (e1 - e0), 0, 1);&#10; return u * u * (3 - 2 * u);&#10; }&#10;&#10; function resize() {&#10; scale = settings.scaleOverride &gt; 0 ? settings.scaleOverride : Math.max(3, Math.floor(Math.min(innerWidth / BASE_W, innerHeight / BASE_H)));&#10; W = Math.ceil(innerWidth / scale);&#10; H = Math.ceil(innerHeight / scale);&#10; pond.width = W;&#10; pond.height = H;&#10; fishCvs.width = W;&#10; fishCvs.height = H;&#10; if (gl) {&#10; gl.activeTexture(gl.TEXTURE0);&#10; canvas.width = W;&#10; canvas.height = H;&#10; canvas.style.width = `${W * scale}px`;&#10; canvas.style.height = `${H * scale}px`;&#10; if (heightFBO) gl.deleteFramebuffer(heightFBO);&#10; gl.bindTexture(gl.TEXTURE_2D, heightTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);&#10; heightFBO = gl.createFramebuffer();&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, heightFBO);&#10; gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, heightTex, 0);&#10; if (rippleFBO) gl.deleteFramebuffer(rippleFBO);&#10; gl.bindTexture(gl.TEXTURE_2D, rippleTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);&#10; rippleFBO = gl.createFramebuffer();&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, rippleFBO);&#10; gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rippleTex, 0);&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, null);&#10; gl.bindTexture(gl.TEXTURE_2D, sceneTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);&#10; gl.bindTexture(gl.TEXTURE_2D, overlayTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, W, H, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);&#10; gl.useProgram(rippleProg);&#10; gl.uniform2f(rippleU.r, W, H);&#10; gl.useProgram(heightProg);&#10; gl.uniform2f(heightU.r, W, H);&#10; gl.useProgram(compProg);&#10; gl.uniform2f(compU.r, W, H);&#10; } else {&#10; canvas.width = Math.ceil(innerWidth);&#10; canvas.height = Math.ceil(innerHeight);&#10; canvas.style.width = "";&#10; canvas.style.height = "";&#10; }&#10; clockSpot = null;&#10; }&#10;&#10; function addWave(x, y, amp, span, decay) {&#10; waves.push({ x, y, age: 0, amp, span, decay, phase: rand(0, Math.PI * 2), fade: 1, retiring: false });&#10; const overflow = waves.length - SOFT_RIPPLE_CAP;&#10; for (let i = 0; i &lt; overflow; i++) waves[i].retiring = true;&#10; }&#10;&#10; function drawWater() {&#10; if (!gl) return;&#10; gl.viewport(0, 0, W, H);&#10;&#10; // Pass 0: render active ripples as batched additive quads&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, rippleFBO);&#10; gl.clearColor(0, 0, 0, 0);&#10; gl.clear(gl.COLOR_BUFFER_BIT);&#10; const maxStart = Math.max(0, waves.length - MAX_UPLOADED_RIPPLES);&#10; let wc = 0;&#10; let off = 0;&#10; for (let i = maxStart; i &lt; waves.length; i++) {&#10; const w = waves[i];&#10; const wa = w.age;&#10; const birth = smoothstep(0.0, 0.32, wa);&#10; const ageFade = 1.0 - smoothstep(1.0 + w.decay * 0.4, 3.8 + w.decay * 0.9, wa);&#10; const ampEff = w.amp * w.fade * birth * ageFade * ageFade;&#10; if (ampEff &lt; 0.0005) continue;&#10; const r = wa * (10.5 + w.span * 2.0);&#10; const b = w.span * 3.9;&#10; const n = r &gt; b ? r - b : 0;&#10; const o = r + b;&#10; const rx = o + 1.5;&#10; const ry = o / 1.55 + 1.5;&#10; const x0 = w.x - rx, x1 = w.x + rx;&#10; const y0 = w.y - ry, y1 = w.y + ry;&#10; if (x1 &lt; 0 || x0 &gt; W || y1 &lt; 0 || y0 &gt; H) continue;&#10; const n2 = n * n, o2 = o * o, invD = 1.0 / (w.span * 1.22), wp = w.phase;&#10; const wx = w.x, wy = w.y;&#10; // 2 triangles (6 vertices), 10 floats per vertex&#10; rippleVerts[off++] = x0; rippleVerts[off++] = y0;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10;&#10; rippleVerts[off++] = x1; rippleVerts[off++] = y0;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10;&#10; rippleVerts[off++] = x0; rippleVerts[off++] = y1;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10;&#10; rippleVerts[off++] = x1; rippleVerts[off++] = y0;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10;&#10; rippleVerts[off++] = x1; rippleVerts[off++] = y1;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10;&#10; rippleVerts[off++] = x0; rippleVerts[off++] = y1;&#10; rippleVerts[off++] = wx; rippleVerts[off++] = wy; rippleVerts[off++] = r; rippleVerts[off++] = ampEff;&#10; rippleVerts[off++] = n2; rippleVerts[off++] = o2; rippleVerts[off++] = invD; rippleVerts[off++] = wp;&#10; wc++;&#10; }&#10; if (wc &gt; 0) {&#10; gl.useProgram(rippleProg);&#10; gl.bindBuffer(gl.ARRAY_BUFFER, rippleBuf);&#10; gl.bufferSubData(gl.ARRAY_BUFFER, 0, rippleVerts.subarray(0, off));&#10; gl.enableVertexAttribArray(0);&#10; gl.enableVertexAttribArray(1);&#10; gl.enableVertexAttribArray(2);&#10; gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 40, 0);&#10; gl.vertexAttribPointer(1, 4, gl.FLOAT, false, 40, 8);&#10; gl.vertexAttribPointer(2, 4, gl.FLOAT, false, 40, 24);&#10; gl.enable(gl.BLEND);&#10; gl.blendFunc(gl.ONE, gl.ONE);&#10; gl.drawArrays(gl.TRIANGLES, 0, wc * 6);&#10; gl.disable(gl.BLEND);&#10; gl.disableVertexAttribArray(1);&#10; gl.disableVertexAttribArray(2);&#10; gl.bindBuffer(gl.ARRAY_BUFFER, quadBuf);&#10; gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);&#10; }&#10;&#10; // Pass 1: base water heightfield + caustics + cycle/shade&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, heightFBO);&#10; gl.useProgram(heightProg);&#10; glTimes[0] = t * .46;&#10; glTimes[1] = t * .39;&#10; glTimes[2] = t * .24;&#10; glTimes[3] = t * 2.9;&#10; glTimes[4] = t * 2.35;&#10; glTimes[5] = t * 3.3;&#10; gl.uniform1fv(heightU.t, glTimes);&#10; gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);&#10; gl.bindFramebuffer(gl.FRAMEBUFFER, null);&#10; }&#10;&#10; function drawWaterVeil() {}&#10;&#10; const FISH_PROFILE = [&#10; [-0.50, 0.10], [-0.36, 0.46], [-0.18, 0.88], [0.04, 1.00],&#10; [0.25, 0.83], [0.42, 0.56], [0.52, 0.18]&#10; ];&#10; const FISH_PROFILE_U = [-0.50, -0.36, -0.18, 0.04, 0.25, 0.42, 0.52];&#10; const FISH_PROFILE_W = [0.10, 0.46, 0.88, 1.00, 0.83, 0.56, 0.18];&#10;&#10; function resetFish(k, i, fromEdge) {&#10; const schemes = [&#10; { base: PAL.white, mid: PAL.pearl, spot: PAL.orange, spot2: PAL.orange2, fin: PAL.white },&#10; { base: PAL.orange, mid: PAL.orange2, spot: PAL.red, spot2: PAL.cream, fin: PAL.orange },&#10; { base: PAL.cream, mid: PAL.white, spot: PAL.black, spot2: PAL.orange, fin: PAL.cream },&#10; { base: PAL.white, mid: PAL.pearl, spot: PAL.black, spot2: PAL.red, fin: PAL.white },&#10; { base: PAL.gold, mid: PAL.cream, spot: PAL.charcoal, spot2: PAL.orange, fin: PAL.gold },&#10; { base: PAL.silver, mid: PAL.pearl, spot: PAL.charcoal, spot2: PAL.black, fin: PAL.silver }&#10; ];&#10; const len = rand(48, 66);&#10; const side = Math.floor(rand(0, 4));&#10; let x = rand(40, W - 40);&#10; let y = rand(35, H - 35);&#10; let a = rand(0, Math.PI * 2);&#10; let goalX = rand(30, W - 30);&#10; let goalY = rand(25, H - 25);&#10; let roamMode = Math.random() &lt; 0.24 ? "mill" : "cross";&#10; let millX = x;&#10; let millY = y;&#10; let millA = rand(0, Math.PI * 2);&#10; if (fromEdge) {&#10; const m = len * 1.2;&#10; if (side === 0) { x = -m; y = rand(20, H - 20); goalX = W + m; goalY = rand(20, H - 20); }&#10; if (side === 1) { x = W + m; y = rand(20, H - 20); goalX = -m; goalY = rand(20, H - 20); }&#10; if (side === 2) { x = rand(20, W - 20); y = -m; goalX = rand(20, W - 20); goalY = H + m; }&#10; if (side === 3) { x = rand(20, W - 20); y = H + m; goalX = rand(20, W - 20); goalY = -m; }&#10; a = Math.atan2(goalY - y, goalX - x) + rand(-0.22, 0.22);&#10; roamMode = "cross";&#10; millX = clamp(x, 30, W - 30);&#10; millY = clamp(y, 25, H - 25);&#10; }&#10;&#10; const depth = clamp((66 - len) / 18 + rand(-0.12, 0.18), 0, 1);&#10; Object.assign(k, {&#10; x,&#10; y,&#10; a,&#10; speed: rand(48, 68),&#10; vel: rand(48, 68),&#10; acc: 0,&#10; turnVel: 0,&#10; curve: 0,&#10; cruise: rand(92, 126),&#10; goalX,&#10; goalY,&#10; goalClock: rand(5, 16),&#10; roamMode,&#10; millX,&#10; millY,&#10; millA,&#10; turnBias: rand(-0.18, 0.18),&#10; len,&#10; depth,&#10; width: len * rand(0.16, 0.20),&#10; phase: rand(0, Math.PI * 2),&#10; lastPulse: 0,&#10; effort: rand(0.35, 0.8),&#10; thrust: 0,&#10; visualThrust: 0,&#10; hunger: rand(0.35, 1),&#10; feedCaps: Object.create(null),&#10; rest: rand(10, 24),&#10; restLimit: rand(0.45, 1.1),&#10; wake: 0,&#10; scheme: schemes[i % schemes.length],&#10; pattern: Math.random() &lt; 0.60 ? "noise" : "classic",&#10; texture: null,&#10; top: Array.from({ length: FISH_PROFILE.length }, () =&gt; [0, 0]),&#10; bot: Array.from({ length: FISH_PROFILE.length }, () =&gt; [0, 0]),&#10; insetTop: Array.from({ length: FISH_PROFILE.length }, () =&gt; [0, 0]),&#10; insetBot: Array.from({ length: FISH_PROFILE.length }, () =&gt; [0, 0])&#10; });&#10; const tint = k.depth * 0.52;&#10; k.drawScheme = {&#10; base: mixHex(k.scheme.base, PAL.water[5], tint),&#10; mid: mixHex(k.scheme.mid, PAL.water[4], tint),&#10; spot: mixHex(k.scheme.spot, PAL.water[3], tint * 0.85),&#10; spot2: mixHex(k.scheme.spot2, PAL.water[3], tint * 0.85),&#10; fin: mixHex(k.scheme.fin, PAL.water[5], tint)&#10; };&#10; if (k.pattern === "noise") {&#10; k.texture = generateKoiTexture(k.drawScheme);&#10; }&#10; }&#10;&#10; function spawnFish(i, fromEdge = false) {&#10; const k = {};&#10; resetFish(k, i, fromEdge);&#10; fish.push(k);&#10; }&#10;&#10; function canEatPellet(k, batch) {&#10; let cap = k.feedCaps[batch];&#10; if (!cap) cap = k.feedCaps[batch] = { limit: Math.floor(rand(1, 5)), eaten: 0 };&#10; return cap.eaten &lt; cap.limit;&#10; }&#10;&#10; function markPelletEaten(k, batch) {&#10; const cap = k.feedCaps[batch] || (k.feedCaps[batch] = { limit: Math.floor(rand(1, 5)), eaten: 0 });&#10; cap.eaten++;&#10; }&#10;&#10; function padRadius(p) {&#10; return p.r + 14;&#10; }&#10;&#10; function findClockSpot() {&#10; const x = settings.clockX === null ? W * 0.5 : settings.clockX;&#10; const y = settings.clockY === null ? H * 0.5 : settings.clockY;&#10; const spot = { x, y, vx: 0, vy: 0, bob: rand(0, Math.PI * 2) };&#10; clockSpot = spot;&#10; clampClockSpot();&#10; return spot;&#10; }&#10;&#10; function clockBounds() {&#10; const size = Math.round(20 * settings.clockScale);&#10; const width = (settings.clockFormat === "secs" ? 74 : 54) * settings.clockScale;&#10; const height = settings.clockDate ? size * 1.75 : size * 0.8;&#10; return {&#10; x: Math.ceil(width * 0.5 + 4),&#10; y: Math.ceil(height * 0.5 + 4)&#10; };&#10; }&#10;&#10; function clampClockSpot() {&#10; if (!clockSpot) return;&#10; const bounds = clockBounds();&#10; clockSpot.x = clamp(clockSpot.x, bounds.x, W - bounds.x);&#10; clockSpot.y = clamp(clockSpot.y, bounds.y, H - bounds.y);&#10; }&#10;&#10; function isClockHit(x, y) {&#10; if (!settings.clock) return false;&#10; if (!clockSpot) clockSpot = findClockSpot();&#10; const bounds = clockBounds();&#10; return Math.abs(x - clockSpot.x) &lt;= bounds.x &amp;&amp; Math.abs(y - clockSpot.y) &lt;= bounds.y;&#10; }&#10;&#10; function bakePadSprite(p) {&#10; const half = Math.ceil(p.r * 1.12 + 8);&#10; const ss = 2;&#10; const size = half * 2 * ss;&#10; const sc = document.createElement("canvas");&#10; sc.width = size;&#10; sc.height = size;&#10; const sctx = sc.getContext("2d");&#10; sctx.scale(ss, ss);&#10; sctx.translate(half, half);&#10;&#10; const n = p.edge.length;&#10; const cutStart = Math.floor(p.cutAngle / (Math.PI * 2) * n);&#10; const cutEnd = n - cutStart;&#10;&#10; function edgePath() {&#10; sctx.beginPath();&#10; let started = false;&#10; for (let i = cutStart; i &lt; cutEnd; i++) {&#10; const angle = (i / n) * Math.PI * 2;&#10; const rr = p.r * p.edge[i];&#10; const x = Math.cos(angle) * rr;&#10; const y = Math.sin(angle) * rr;&#10; if (!started) { sctx.moveTo(x, y); started = true; }&#10; else sctx.lineTo(x, y);&#10; }&#10; sctx.lineTo(0, 0);&#10; sctx.closePath();&#10; }&#10;&#10; sctx.fillStyle = "rgba(4, 19, 29, .18)";&#10; sctx.beginPath();&#10; for (let i = 0; i &lt; n; i++) {&#10; const angle = (i / n) * Math.PI * 2;&#10; const rr = p.r * p.edge[i];&#10; const x = Math.cos(angle) * rr + 4;&#10; const y = Math.sin(angle) * rr + 5;&#10; if (i === 0) sctx.moveTo(x, y);&#10; else sctx.lineTo(x, y);&#10; }&#10; sctx.closePath();&#10; sctx.fill();&#10;&#10; const diam = p.r * 2;&#10; sctx.save();&#10; edgePath();&#10; sctx.clip();&#10; sctx.drawImage(p.texture, -p.r, -p.r, diam, diam);&#10; sctx.restore();&#10;&#10; sctx.strokeStyle = PAL.rim;&#10; sctx.lineWidth = 1.2;&#10; edgePath();&#10; sctx.stroke();&#10;&#10; if (p.flower) {&#10; const fx = p.r * 0.05, fy = -p.r * 0.05;&#10; const colors = {&#10; white: ["#f0ebe0", "#e8e2d4", "#fff8f0"],&#10; pink: ["#e6a7b1", "#d4899a", "#f0c0cc"],&#10; violet: ["#b48cc4", "#9a6eae", "#c8a4d4"]&#10; };&#10; const c = colors[p.flowerColor];&#10; const petalCount = p.flowerPetals;&#10; const petalR = p.r * 0.38;&#10; for (let i = 0; i &lt; petalCount; i++) {&#10; const a = (i / petalCount) * Math.PI * 2;&#10; sctx.fillStyle = c[i % 3];&#10; sctx.beginPath();&#10; sctx.ellipse(fx + Math.cos(a) * petalR * 0.5, fy + Math.sin(a) * petalR * 0.5, petalR * 0.42, petalR * 0.24, a, 0, Math.PI * 2);&#10; sctx.fill();&#10; }&#10; sctx.fillStyle = "#ffe0c0";&#10; sctx.beginPath();&#10; sctx.arc(fx, fy, petalR * 0.18, 0, Math.PI * 2);&#10; sctx.fill();&#10; }&#10; p.sprite = sc;&#10; p.spriteHalf = half;&#10; p.texture = null;&#10; }&#10;&#10; function buildPads() {&#10; pads.length = 0;&#10; const target = Math.max(0, Math.floor(Math.max(7, W * H / 9200) * settings.padScale));&#10; let attempts = 0;&#10; while (pads.length &lt; target &amp;&amp; attempts++ &lt; target * 80) {&#10; const r = rand(18, 38);&#10; const x = rand(r, W - r);&#10; const y = rand(r, H - r);&#10; let ok = true;&#10; for (const q of pads) {&#10; const dx = x - q.x;&#10; const dy = y - q.y;&#10; const minD = (r + 14) + padRadius(q) - rand(6, 18);&#10; if (dx * dx + dy * dy &lt; minD * minD) {&#10; ok = false;&#10; break;&#10; }&#10; }&#10; if (!ok) continue;&#10;&#10; const seed = rand(0, 999);&#10; const cutAngle = rand(0.15, 0.45);&#10; const n = 24;&#10; const edge = [];&#10; for (let i = 0; i &lt; n; i++) {&#10; const angle = (i / n) * Math.PI * 2;&#10; const jitter = fbm(seed + Math.cos(angle) * 2.5, seed + Math.sin(angle) * 2.5, 3) * 0.18 - 0.09;&#10; edge.push(1 + jitter);&#10; }&#10; const flowerColor = ["white", "pink", "violet"][Math.floor(Math.random() * 3)];&#10; const flowerPetals = Math.floor(rand(6, 9));&#10; const veinCount = Math.floor(rand(6, 10));&#10; const veins = Array.from({ length: veinCount }, (_, i) =&gt; {&#10; const a = (i / veinCount) * Math.PI * 2 + rand(-0.08, 0.08);&#10; const normA = ((a % (Math.PI * 2)) + Math.PI * 2) % (Math.PI * 2);&#10; const normCut = cutAngle;&#10; const nearCut = Math.abs(normA - normCut) &lt; 0.4 || Math.abs(normA - (Math.PI * 2 - normCut)) &lt; 0.4;&#10; return { angle: a, len: nearCut ? rand(0.25, 0.45) : rand(0.78, 0.95), curve: rand(-0.03, 0.03) };&#10; });&#10; const p = {&#10; x,&#10; y,&#10; r,&#10; edge,&#10; cutAngle,&#10; a: rand(0, Math.PI * 2),&#10; vx: 0,&#10; vy: 0,&#10; bob: rand(0, Math.PI * 2),&#10; texture: generatePadTexture(r, veins),&#10; veins,&#10; flower: Math.random() &lt; 0.35,&#10; flowerColor,&#10; flowerPetals,&#10; sprite: null,&#10; spriteHalf: 0&#10; };&#10; bakePadSprite(p);&#10; pads.push(p);&#10; }&#10; clockSpot = null;&#10; }&#10;&#10; function scheduleFeed(now) {&#10; nextFeed = now + rand(10000, 60000);&#10; }&#10;&#10; function updatePopulation(now, dt) {&#10; targetFish = settings.fishCap;&#10;&#10; if (fish.length &lt; targetFish &amp;&amp; Math.random() &lt; 0.018) spawnFish(fish.length, true);&#10;&#10; if (now &gt;= nextSchool) {&#10; if (fish.length &gt;= 5 &amp;&amp; Math.random() &lt; 0.40) {&#10; schoolUntil = now + rand(8000, 16000);&#10; schoolTarget = { x: rand(W * 0.15, W * 0.85), y: rand(H * 0.15, H * 0.85) };&#10; schoolTargetClock = 0;&#10; } else {&#10; schoolUntil = 0;&#10; schoolTarget = null;&#10; }&#10; nextSchool = now + rand(17000, 42000);&#10; }&#10;&#10; if (schoolTarget) {&#10; schoolTargetClock -= dt;&#10; if (schoolTargetClock &lt; 0) {&#10; const prev = schoolTarget;&#10; schoolTarget = { x: clamp(prev.x + rand(-100, 100), 30, W - 30), y: clamp(prev.y + rand(-80, 80), 20, H - 20) };&#10; schoolTargetClock = rand(1.5, 3.5);&#10; }&#10; }&#10; }&#10;&#10; function dropFeedAt(cx, cy, now) {&#10; feedBatch++;&#10; const count = Math.floor(rand(5, 10));&#10; for (let i = 0; i &lt; count; i++) {&#10; const a = rand(0, Math.PI * 2);&#10; const d = rand(0, 18);&#10; pellets.push({&#10; x: cx + Math.cos(a) * d,&#10; y: cy + Math.sin(a) * d,&#10; bob: rand(0, Math.PI * 2),&#10; age: 0,&#10; batch: feedBatch&#10; });&#10; }&#10; for (let i = 0; i &lt; 5; i++) addWave(cx + rand(-12, 12), cy + rand(-10, 10), rand(0.8, 1.6), rand(3.2, 6), rand(0.32, 0.48));&#10; }&#10;&#10; function dropFeed(now) {&#10; dropFeedAt(rand(65, W - 65), rand(45, H - 45), now);&#10; scheduleFeed(now);&#10; }&#10;&#10; function update(dt, now) {&#10; t += dt;&#10; updatePopulation(now, dt);&#10; if (settings.autoFeed &amp;&amp; now &gt;= nextFeed) dropFeed(now);&#10; if (!settings.autoFeed) nextFeed = now + 10000;&#10;&#10; for (const w of waves) {&#10; w.age += dt;&#10; if (!w.retiring &amp;&amp; w.age * w.decay &gt; RIPPLE_RETIRE_AGE) w.retiring = true;&#10; if (w.retiring) w.fade += (0 - w.fade) * dt * RIPPLE_FADE_SPEED;&#10; }&#10; for (let i = waves.length - 1; i &gt;= 0; i--) {&#10; if (waves[i].fade &lt; 0.02) waves.splice(i, 1);&#10; }&#10;&#10; for (const pellet of pellets) {&#10; pellet.age += dt;&#10; pellet.x += Math.sin(t * 0.8 + pellet.bob) * dt * 1.2;&#10; pellet.y += Math.cos(t * 0.65 + pellet.bob) * dt * 0.9;&#10; if (Math.random() &lt; dt * 0.7) addWave(pellet.x, pellet.y, 0.26, 3.5, 0.62);&#10; }&#10;&#10; for (const k of fish) {&#10; let ca = Math.cos(k.a);&#10; let sa = Math.sin(k.a);&#10; k.goalClock -= dt;&#10; const gdx = k.goalX - k.x;&#10; const gdy = k.goalY - k.y;&#10; if ((k.goalClock &lt; 0 || gdx * gdx + gdy * gdy &lt; k.len * k.len) &amp;&amp; !schoolTarget) {&#10; const margin = k.len * 1.2;&#10; k.roamMode = Math.random() &lt; 0.28 ? "mill" : "cross";&#10; if (k.roamMode === "mill") {&#10; k.millX = clamp(k.x + rand(-65, 65), 35, W - 35);&#10; k.millY = clamp(k.y + rand(-45, 45), 30, H - 30);&#10; k.millA = Math.atan2(k.y - k.millY, k.x - k.millX) + rand(-0.6, 0.6);&#10; k.goalClock = rand(5, 12);&#10; } else {&#10; k.goalX = rand(-margin, W + margin);&#10; k.goalY = rand(-margin, H + margin);&#10; k.goalClock = rand(8, 22);&#10; }&#10; }&#10;&#10; if (k.roamMode === "mill") {&#10; const radius = k.len * 1.1;&#10; k.millA += dt * (0.55 + k.vel * 0.006);&#10; k.goalX = k.millX + Math.cos(k.millA) * radius;&#10; k.goalY = k.millY + Math.sin(k.millA) * radius * 0.75;&#10; }&#10;&#10; let target = Math.atan2(k.goalY - k.y, k.goalX - k.x) + Math.sin(t * 0.35 + k.phase) * 0.18 + k.turnBias * 0.35;&#10; let close = null;&#10; let closeD = Infinity;&#10;&#10; for (const p of pellets) {&#10; if (!canEatPellet(k, p.batch)) continue;&#10; const dx = p.x - k.x;&#10; const dy = p.y - k.y;&#10; const d = dx * dx + dy * dy;&#10; if (d &lt; closeD) {&#10; closeD = d;&#10; close = p;&#10; }&#10; }&#10;&#10; k.rest -= dt;&#10; const resting = k.rest &lt; 0 &amp;&amp; !(schoolTarget &amp;&amp; !close);&#10; if (k.rest &lt; -k.restLimit) {&#10; k.rest = rand(4, 13);&#10; k.restLimit = rand(0.8, 2.2);&#10; }&#10;&#10; if (close &amp;&amp; k.hunger &gt; 0.14 &amp;&amp; !resting) {&#10; target = Math.atan2(close.y - k.y, close.x - k.x);&#10; k.cruise = Math.min(148, k.cruise + dt * 38);&#10; } else if (!resting) {&#10; k.cruise += (rand(92, 126) - k.cruise) * dt * 0.18;&#10; }&#10;&#10; if (schoolTarget &amp;&amp; !close &amp;&amp; !resting) {&#10; const dx = schoolTarget.x - k.x;&#10; const dy = schoolTarget.y - k.y;&#10; const d = Math.sqrt(dx * dx + dy * dy) || 1;&#10; const toTarget = Math.atan2(dy, dx);&#10; const tangent = toTarget + Math.PI * 0.5;&#10; const spread = clamp(d / 80, 0, 0.8);&#10; const final = Math.atan2(Math.sin(toTarget) * (1 - spread) + Math.sin(tangent) * spread,&#10; Math.cos(toTarget) * (1 - spread) + Math.cos(tangent) * spread);&#10; target = Math.atan2(Math.sin(target) * 0.3 + Math.sin(final) * 0.7,&#10; Math.cos(target) * 0.3 + Math.cos(final) * 0.7);&#10; k.cruise += (140 - k.cruise) * dt * 0.3;&#10; }&#10;&#10; let repelX = 0;&#10; let repelY = 0;&#10; const noseX = k.x + ca * k.len * 0.28;&#10; const noseY = k.y + sa * k.len * 0.28;&#10; for (const p of pads) {&#10; const dx = noseX - p.x;&#10; const dy = noseY - p.y;&#10; const d = Math.sqrt(dx * dx + dy * dy) || 1;&#10; const r = padRadius(p);&#10; if (d &lt; r) {&#10; const push = (r - d) / r;&#10; repelX += dx / d * push;&#10; repelY += dy / d * push;&#10; }&#10; }&#10;&#10; for (const other of fish) {&#10; if (other === k) continue;&#10; const kpx = k.x + ca * k.vel * 0.75;&#10; const kpy = k.y + sa * k.vel * 0.75;&#10; const opx = other.x + Math.cos(other.a) * other.vel * 0.75;&#10; const opy = other.y + Math.sin(other.a) * other.vel * 0.75;&#10; const dx = kpx - opx;&#10; const dy = kpy - opy;&#10; const d2 = dx * dx + dy * dy;&#10; const r = (k.len + other.len) * 0.62;&#10; if (d2 &gt; 0.01 &amp;&amp; d2 &lt; r * r) {&#10; const d = Math.sqrt(d2);&#10; const push = (r - d) / r;&#10; repelX += dx / d * push * 1.15;&#10; repelY += dy / d * push * 1.15;&#10; }&#10; }&#10;&#10; if (repelX || repelY) {&#10; const avoid = Math.atan2(repelY, repelX);&#10; const mix = clamp(Math.hypot(repelX, repelY) * 0.85, 0, 0.92);&#10; target = Math.atan2(&#10; Math.sin(target) * (1 - mix) + Math.sin(avoid) * mix,&#10; Math.cos(target) * (1 - mix) + Math.cos(avoid) * mix&#10; );&#10; k.cruise *= 0.994;&#10; }&#10;&#10; const da = Math.atan2(Math.sin(target - k.a), Math.cos(target - k.a));&#10; const turnGoal = clamp(da * 2.25, -1.35, 1.35);&#10; k.turnVel += (turnGoal - k.turnVel) * dt * 3.2;&#10; k.turnVel *= Math.pow(0.90, dt * 60);&#10; k.a += k.turnVel * dt;&#10; k.curve += (k.turnVel - k.curve) * dt * 5.0;&#10; ca = Math.cos(k.a);&#10; sa = Math.sin(k.a);&#10;&#10; const desiredEffort = resting ? 0.12 : clamp((k.cruise - k.vel) / 46 + Math.abs(da) * 0.14 + (close ? 0.35 : 0), 0.30, 1.25);&#10; k.effort += (desiredEffort - k.effort) * dt * 2.0;&#10; const beatRate = resting ? 1.1 : 1.45 + k.vel * 0.108 + k.effort * 1.95;&#10; const oldPulse = Math.max(0, Math.sin(k.phase));&#10; k.phase += dt * beatRate;&#10; const pulse = Math.max(0, Math.sin(k.phase));&#10; k.thrust = Math.max(0, pulse - oldPulse) * k.effort;&#10; k.visualThrust += (k.thrust - k.visualThrust) * dt * 7.5;&#10; const oldVel = k.vel;&#10; const drive = k.thrust * (resting ? 28 : 212);&#10; const glide = (resting ? 0.8 - k.vel : k.cruise - k.vel) * 0.26;&#10; const drag = k.vel * k.vel * 0.0009;&#10; k.acc = drive + glide - drag;&#10; k.vel = clamp(k.vel + k.acc * dt, 0, 160);&#10; k.vel *= Math.pow(resting ? 0.982 : 0.997, dt * 60);&#10; k.acc = (k.vel - oldVel) / Math.max(dt, 0.001);&#10; k.speed = k.vel;&#10; k.x += ca * k.vel * dt;&#10; k.y += sa * k.vel * dt;&#10; k.hunger = Math.min(1, k.hunger + dt * 0.018);&#10; k.wake -= dt;&#10;&#10; for (const p of pads) {&#10; const dx = p.x - k.x;&#10; const dy = p.y - k.y;&#10; const d2 = dx * dx + dy * dy;&#10; const r = padRadius(p) + k.len * 0.45;&#10; if (d2 &gt; 1 &amp;&amp; d2 &lt; r * r) {&#10; const d = Math.sqrt(d2);&#10; const push = (1 - d / r) * k.vel * dt * 0.018;&#10; p.vx += dx / d * push;&#10; p.vy += dy / d * push;&#10; }&#10; }&#10; if (settings.clock &amp;&amp; settings.clockMovement &amp;&amp; clockSpot) {&#10; const dx = clockSpot.x - k.x;&#10; const dy = clockSpot.y - k.y;&#10; const d2 = dx * dx + dy * dy;&#10; const r = k.len * 0.7 + 34;&#10; if (d2 &gt; 1 &amp;&amp; d2 &lt; r * r) {&#10; const d = Math.sqrt(d2);&#10; const push = (1 - d / r) * k.vel * dt * 0.010;&#10; clockSpot.vx += dx / d * push;&#10; clockSpot.vy += dy / d * push;&#10; }&#10; }&#10;&#10; const margin = k.len * 1.7;&#10; if (k.x &lt; -margin || k.x &gt; W + margin || k.y &lt; -margin || k.y &gt; H + margin) {&#10; if (fish.length &gt; targetFish) {&#10; fish.splice(fish.indexOf(k), 1);&#10; continue;&#10; }&#10; resetFish(k, fish.indexOf(k), true);&#10; continue;&#10; }&#10;&#10; const rippleGain = clamp((k.vel - 5) / 45, 0, 1);&#10; const ripplePower = Math.pow(rippleGain, 1.35);&#10; if (!resting &amp;&amp; ripplePower &gt; 0.05 &amp;&amp; k.wake &lt;= 0) {&#10; const tailX = k.x - ca * k.len * 0.46;&#10; const tailY = k.y - sa * k.len * 0.46;&#10; addWave(tailX, tailY, 0.88 * ripplePower, 5.4, 0.26);&#10; addWave(k.x - sa * k.width * 0.8, k.y + ca * k.width * 0.8, 0.30 * ripplePower, 4.0, 0.36);&#10; addWave(k.x + sa * k.width * 0.8, k.y - ca * k.width * 0.8, 0.30 * ripplePower, 4.0, 0.36);&#10; k.wake = rand(0.18, 0.30) + (1 - ripplePower) * 0.24;&#10; }&#10;&#10; for (let i = pellets.length - 1; i &gt;= 0; i--) {&#10; const p = pellets[i];&#10; if (!canEatPellet(k, p.batch)) continue;&#10; const dx = p.x - (k.x + ca * k.len * 0.32);&#10; const dy = p.y - (k.y + sa * k.len * 0.32);&#10; if (dx * dx + dy * dy &lt; k.width * k.width * 1.7) {&#10; pellets.splice(i, 1);&#10; markPelletEaten(k, p.batch);&#10; k.hunger *= 0.42;&#10; addWave(p.x, p.y, 1.05, 5.6, 0.24);&#10; pops.push({ x: p.x, y: p.y, life: 1 });&#10; break;&#10; }&#10; }&#10; }&#10;&#10; for (let i = pops.length - 1; i &gt;= 0; i--) {&#10; pops[i].life -= dt * 1.4;&#10; pops[i].y -= dt * 4;&#10; if (pops[i].life &lt;= 0) pops.splice(i, 1);&#10; }&#10;&#10; for (const p of pads) {&#10; p.x += p.vx;&#10; p.y += p.vy;&#10; p.vx *= Math.pow(0.90, dt * 60);&#10; p.vy *= Math.pow(0.90, dt * 60);&#10; p.x = clamp(p.x, p.r + 4, W - p.r - 4);&#10; p.y = clamp(p.y, p.r + 4, H - p.r - 4);&#10; }&#10; if (settings.clock &amp;&amp; clockSpot) {&#10; clockSpot.x += clockSpot.vx;&#10; clockSpot.y += clockSpot.vy;&#10; const damping = settings.clockMovement ? 0.91 : 0.82;&#10; clockSpot.vx *= Math.pow(damping, dt * 60);&#10; clockSpot.vy *= Math.pow(damping, dt * 60);&#10; clampClockSpot();&#10; }&#10; }&#10;&#10; function poly(points, color, c) {&#10; c.fillStyle = color;&#10; c.beginPath();&#10; c.moveTo(Math.round(points[0][0]), Math.round(points[0][1]));&#10; for (let i = 1; i &lt; points.length; i++) c.lineTo(Math.round(points[i][0]), Math.round(points[i][1]));&#10; c.closePath();&#10; c.fill();&#10; }&#10;&#10; function drawPad(p) {&#10; pctx.save();&#10; pctx.translate(Math.round(p.x), Math.round(p.y + Math.sin(t * 0.9 + p.bob) * 0.7));&#10; pctx.rotate(p.a + Math.sin(t * 0.16 + p.x) * 0.035);&#10; pctx.drawImage(p.sprite, -p.spriteHalf, -p.spriteHalf, p.spriteHalf * 2, p.spriteHalf * 2);&#10; pctx.restore();&#10; }&#10;&#10; const clockCvs = document.createElement("canvas");&#10; const cctx = clockCvs.getContext("2d");&#10; let clockCacheKey = "";&#10; let clockOriginX = 0;&#10; let clockOriginY = 0;&#10; let clockFontVersion = 0;&#10; if (document.fonts &amp;&amp; document.fonts.ready) {&#10; document.fonts.ready.then(() =&gt; { clockFontVersion++; });&#10; }&#10;&#10; function drawClock() {&#10; if (!settings.clock) return;&#10; if (!clockSpot) clockSpot = findClockSpot();&#10; const date = new Date();&#10; const sec = Math.floor(date.getTime() / 1000);&#10; const key = `${sec}|${settings.clockFormat}|${settings.clockDate}|${settings.clockScale}|${clockFontVersion}`;&#10; if (key !== clockCacheKey) {&#10; clockCacheKey = key;&#10; const time = date.toLocaleTimeString([], {&#10; hour: "2-digit",&#10; minute: "2-digit",&#10; second: settings.clockFormat === "secs" ? "2-digit" : undefined,&#10; hour12: settings.clockFormat === "12"&#10; });&#10; const size = Math.round(20 * settings.clockScale);&#10; const dateSize = Math.max(9, Math.round(size * 0.52));&#10; const gap = Math.max(11, Math.round(size * 0.68));&#10; cctx.font = `${size}px "Instrument Serif", Georgia, serif`;&#10; const timeWidth = cctx.measureText(time).width;&#10; let dateText = "";&#10; let maxW = timeWidth;&#10; if (settings.clockDate) {&#10; const yyyy = date.getFullYear();&#10; const mm = String(date.getMonth() + 1).padStart(2, "0");&#10; const dd = String(date.getDate()).padStart(2, "0");&#10; dateText = `${yyyy}-${mm}-${dd}`;&#10; cctx.font = `${dateSize}px "Instrument Serif", Georgia, serif`;&#10; const dw = cctx.measureText(dateText).width;&#10; if (dw &gt; maxW) maxW = dw;&#10; }&#10; const padX = Math.ceil(size * 0.35) + 6;&#10; const cw = Math.ceil(maxW) + padX * 2;&#10; const cy = Math.ceil(size * 0.75) + 6;&#10; const ch = settings.clockDate ? cy + gap + Math.ceil(dateSize * 0.75) + 6 : cy * 2;&#10; const cx = Math.floor(cw * 0.5);&#10; clockCvs.width = cw;&#10; clockCvs.height = ch;&#10; clockOriginX = cx;&#10; clockOriginY = cy;&#10; cctx.textAlign = "center";&#10; cctx.textBaseline = "middle";&#10; cctx.lineWidth = 2;&#10; cctx.strokeStyle = PAL.water[0];&#10; cctx.fillStyle = "rgba(173, 218, 209, .84)";&#10; cctx.font = `${size}px "Instrument Serif", Georgia, serif`;&#10; cctx.strokeText(time, cx, cy);&#10; cctx.fillText(time, cx, cy);&#10; if (settings.clockDate) {&#10; const dateX = Math.round(cx - timeWidth * 0.5);&#10; cctx.textAlign = "left";&#10; cctx.font = `${dateSize}px "Instrument Serif", Georgia, serif`;&#10; cctx.strokeText(dateText, dateX, cy + gap);&#10; cctx.fillText(dateText, dateX, cy + gap);&#10; }&#10; }&#10; const x = Math.round(clockSpot.x);&#10; const y = Math.round(clockSpot.y + (settings.clockMovement ? Math.sin(t * 0.9 + clockSpot.bob) * 0.7 : 0));&#10; pctx.drawImage(clockCvs, x - clockOriginX, y - clockOriginY);&#10; }&#10;&#10; const fishColX = new Int32Array(32);&#10; const fishColBend = new Float32Array(32);&#10;&#10; function drawFish(k) {&#10; const L = k.len;&#10; const Wd = k.width;&#10; const phase = k.phase;&#10; const curve = k.curve;&#10; const wig = Math.sin(phase);&#10; const accelBend = clamp(Math.max(0, k.acc) / 115, 0, 0.24);&#10; const bendAmp = 0.18 + k.effort * 0.24 + k.visualThrust * 0.24 + accelBend;&#10; const s = k.drawScheme;&#10; const top = k.top;&#10; const bot = k.bot;&#10; const insetTop = k.insetTop;&#10; const insetBot = k.insetBot;&#10; const swimScale = Wd * bendAmp;&#10; const turnScale = -curve * Wd * 0.70;&#10;&#10; function bendAt(u) {&#10; const tailWeight = clamp((0.55 - u) * 1.55, 0, 1);&#10; return Math.sin((u + 0.5) * Math.PI * 1.5 + phase) * swimScale * tailWeight + turnScale * tailWeight * tailWeight;&#10; }&#10;&#10; function pt(u, v) {&#10; return [u * L, v * Wd + bendAt(u)];&#10; }&#10;&#10; for (let i = 0; i &lt; FISH_PROFILE.length; i++) {&#10; const u = FISH_PROFILE_U[i], w = FISH_PROFILE_W[i];&#10; const bend = bendAt(u);&#10; top[i][0] = u * L;&#10; top[i][1] = -w * Wd + bend;&#10; const bi = FISH_PROFILE.length - 1 - i;&#10; bot[bi][0] = u * L;&#10; bot[bi][1] = w * Wd + bend;&#10; }&#10;&#10; fctx.save();&#10; fctx.translate(Math.round(k.x), Math.round(k.y));&#10; fctx.rotate(k.a);&#10;&#10; fctx.fillStyle = "rgba(4, 19, 29, .32)";&#10; fctx.beginPath();&#10; fctx.ellipse(0, 3, L * 0.52, Wd * 0.9, 0, 0, Math.PI * 2);&#10; fctx.fill();&#10;&#10; poly([pt(-0.48, 0.02), pt(-0.72, -0.72), pt(-0.60, -0.03), pt(-0.72, 0.72)], s.fin, fctx);&#10; poly([pt(-0.52, 0.00), pt(-0.78, -0.42), pt(-0.67, 0.00), pt(-0.78, 0.42)], s.spot, fctx);&#10; poly([pt(-0.04, -0.68), pt(-0.28, -1.34 - wig * 0.22), pt(-0.18, -0.18)], s.fin, fctx);&#10; poly([pt(-0.04, 0.68), pt(-0.28, 1.34 + wig * 0.22), pt(-0.18, 0.18)], s.fin, fctx);&#10;&#10; fctx.fillStyle = PAL.dark;&#10; fctx.beginPath();&#10; fctx.moveTo(Math.round(top[0][0]), Math.round(top[0][1]));&#10; for (let i = 1; i &lt; top.length; i++) fctx.lineTo(Math.round(top[i][0]), Math.round(top[i][1]));&#10; for (let i = 0; i &lt; bot.length; i++) fctx.lineTo(Math.round(bot[i][0]), Math.round(bot[i][1]));&#10; fctx.closePath();&#10; fctx.fill();&#10;&#10; for (let i = 0; i &lt; top.length; i++) {&#10; insetTop[i][0] = top[i][0] * 0.985 + L * 0.004;&#10; insetTop[i][1] = top[i][1] * 0.86;&#10; insetBot[i][0] = bot[i][0] * 0.985 + L * 0.004;&#10; insetBot[i][1] = bot[i][1] * 0.86;&#10; }&#10; fctx.fillStyle = s.base;&#10; fctx.beginPath();&#10; fctx.moveTo(Math.round(insetTop[0][0]), Math.round(insetTop[0][1]));&#10; for (let i = 1; i &lt; insetTop.length; i++) fctx.lineTo(Math.round(insetTop[i][0]), Math.round(insetTop[i][1]));&#10; for (let i = 0; i &lt; insetBot.length; i++) fctx.lineTo(Math.round(insetBot[i][0]), Math.round(insetBot[i][1]));&#10; fctx.closePath();&#10; fctx.fill();&#10;&#10; if (k.pattern === "classic") {&#10; poly([pt(0.12, -0.54), pt(0.37, -0.32), pt(0.42, 0.22), pt(0.05, 0.50), pt(-0.03, 0.05)], s.mid, fctx);&#10; poly([pt(-0.24, -0.48), pt(-0.02, -0.42), pt(0.04, 0.22), pt(-0.18, 0.50), pt(-0.32, 0.04)], s.spot, fctx);&#10; poly([pt(-0.46, -0.20), pt(-0.28, -0.30), pt(-0.20, 0.24), pt(-0.42, 0.34)], s.spot2, fctx);&#10; poly([pt(0.22, -0.44), pt(0.45, -0.20), pt(0.35, 0.08), pt(0.16, 0.02)], s.spot, fctx);&#10; } else if (k.texture) {&#10; for (let col = 0; col &lt; 32; col++) {&#10; const u = KOI_COLS_U[col];&#10; fishColX[col] = Math.round(u * L);&#10; fishColBend[col] = bendAt(u);&#10; }&#10; fctx.save();&#10; fctx.beginPath();&#10; for (let i = 0; i &lt; insetTop.length; i++) fctx.lineTo(insetTop[i][0], insetTop[i][1]);&#10; for (let i = 0; i &lt; insetBot.length; i++) fctx.lineTo(insetBot[i][0], insetBot[i][1]);&#10; fctx.closePath();&#10; fctx.clip();&#10; const groups = k.texture._runGroups;&#10; for (let g = 0; g &lt; groups.length; g++) {&#10; const group = groups[g];&#10; fctx.fillStyle = group.color;&#10; const runs = group.runs;&#10; for (let i = 0; i &lt; runs.length; i += 3) {&#10; const col = runs[i];&#10; const bend = fishColBend[col];&#10; const y0 = Math.round(runs[i + 1] * Wd + bend);&#10; const y1 = Math.round(runs[i + 2] * Wd + bend);&#10; fctx.fillRect(fishColX[col], y0, 2, y1 - y0 + 2);&#10; }&#10; }&#10; fctx.restore();&#10; }&#10;&#10; fctx.fillStyle = PAL.black;&#10; fctx.fillRect(Math.round(L * 0.43), Math.round(-Wd * 0.32), 3, 3);&#10; fctx.fillRect(Math.round(L * 0.43), Math.round(Wd * 0.17), 3, 3);&#10;&#10; fctx.restore();&#10; }&#10;&#10; function drawPellet(p) {&#10; const x = Math.round(p.x);&#10; const y = Math.round(p.y + Math.sin(t * 3 + p.bob));&#10; pctx.fillStyle = PAL.dark;&#10; pctx.fillRect(x + 1, y + 1, 4, 4);&#10; pctx.fillStyle = PAL.pellet;&#10; pctx.fillRect(x, y, 4, 4);&#10; pctx.fillStyle = PAL.pelletHi;&#10; pctx.fillRect(x, y, 2, 2);&#10; }&#10;&#10; function drawPop(p) {&#10; pctx.fillStyle = `rgba(212, 239, 230, ${p.life * 0.7})`;&#10; pctx.fillRect(Math.round(p.x), Math.round(p.y), 3, 3);&#10; }&#10;&#10; function draw() {&#10; drawWater();&#10; fctx.clearRect(0, 0, W, H);&#10; fishDraw.length = fish.length;&#10; for (let i = 0; i &lt; fish.length; i++) fishDraw[i] = fish[i];&#10; fishDraw.sort((a, b) =&gt; b.depth - a.depth);&#10; for (const k of fishDraw) drawFish(k);&#10;&#10; pctx.clearRect(0, 0, W, H);&#10; drawWaterVeil();&#10; for (const p of pads) drawPad(p);&#10; drawClock();&#10; for (const p of pellets) drawPellet(p);&#10; for (const p of pops) drawPop(p);&#10;&#10; if (gl) {&#10; gl.viewport(0, 0, W, H);&#10; gl.useProgram(compProg);&#10; gl.uniform1fv(compU.t, glTimes);&#10; gl.activeTexture(gl.TEXTURE0);&#10; gl.bindTexture(gl.TEXTURE_2D, heightTex);&#10; gl.activeTexture(gl.TEXTURE1);&#10; gl.bindTexture(gl.TEXTURE_2D, sceneTex);&#10; gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, fishCvs);&#10; gl.activeTexture(gl.TEXTURE2);&#10; gl.bindTexture(gl.TEXTURE_2D, overlayTex);&#10; gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, pond);&#10; gl.activeTexture(gl.TEXTURE5);&#10; gl.bindTexture(gl.TEXTURE_2D, rippleTex);&#10; gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);&#10; } else {&#10; ctx.imageSmoothingEnabled = false;&#10; ctx.fillStyle = PAL.water[0];&#10; ctx.fillRect(0, 0, canvas.width, canvas.height);&#10; ctx.drawImage(fishCvs, 0, 0, W * scale, H * scale);&#10; ctx.drawImage(pond, 0, 0, W * scale, H * scale);&#10; }&#10; }&#10;&#10; function frame(now) {&#10; const dt = Math.min(0.05, (now - last) / 1000);&#10; last = now;&#10; update(dt, now);&#10; draw();&#10; requestAnimationFrame(frame);&#10; }&#10;&#10; loadSettingsFromUrl();&#10; if (gl) {&#10; const palData = new Uint8Array(8 * 4);&#10; for (let i = 0; i &lt; 8; i++) {&#10; const rgb = hexToRGB(PAL.water[i]);&#10; palData[i * 4] = rgb[0]; palData[i * 4 + 1] = rgb[1]; palData[i * 4 + 2] = rgb[2]; palData[i * 4 + 3] = 255;&#10; }&#10; gl.activeTexture(gl.TEXTURE3);&#10; gl.bindTexture(gl.TEXTURE_2D, bayerTex);&#10; gl.activeTexture(gl.TEXTURE4);&#10; gl.bindTexture(gl.TEXTURE_2D, palTex);&#10; gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 8, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, palData);&#10; gl.activeTexture(gl.TEXTURE0);&#10; gl.useProgram(compProg);&#10; gl.uniform3fv(compU.p0, hexRGB(PAL.water[0]));&#10; gl.uniform3fv(compU.p6, hexRGB(PAL.water[6]));&#10; gl.uniform3fv(compU.p7, hexRGB(PAL.water[7]));&#10; gl.uniform3fv(compU.f, hexRGB(PAL.foam));&#10; }&#10; resize();&#10; buildPads();&#10; targetFish = settings.fishCap;&#10; nextSchool = performance.now() + rand(9000, 22000);&#10; for (let i = 0; i &lt; targetFish; i++) spawnFish(i);&#10; scheduleFeed(performance.now());&#10;&#10; addEventListener("resize", () =&gt; {&#10; resize();&#10; buildPads();&#10; });&#10;&#10; function showControls() {&#10; controls.classList.add("visible");&#10; clearTimeout(controlsTimer);&#10; controlsTimer = setTimeout(() =&gt; controls.classList.remove("visible"), 1000);&#10; }&#10;&#10; addEventListener("mousemove", showControls);&#10; addEventListener("mouseleave", () =&gt; {&#10; clearTimeout(controlsTimer);&#10; controls.classList.remove("visible");&#10; });&#10;&#10; autoFeedInput.addEventListener("change", () =&gt; {&#10; settings.autoFeed = autoFeedInput.checked;&#10; if (settings.autoFeed) scheduleFeed(performance.now());&#10; writeSettingsToUrl();&#10; });&#10;&#10; clockInput.addEventListener("change", () =&gt; {&#10; settings.clock = clockInput.checked;&#10; clockSpot = null;&#10; writeSettingsToUrl();&#10; });&#10;&#10; clockScaleInput.addEventListener("input", () =&gt; {&#10; settings.clockScale = Number(clockScaleInput.value);&#10; clockSpot = null;&#10; writeSettingsToUrl();&#10; });&#10;&#10; clockFormatInput.addEventListener("change", () =&gt; {&#10; settings.clockFormat = clockFormatInput.value;&#10; writeSettingsToUrl();&#10; });&#10;&#10; clockDateInput.addEventListener("change", () =&gt; {&#10; settings.clockDate = clockDateInput.checked;&#10; clockSpot = null;&#10; writeSettingsToUrl();&#10; });&#10;&#10; clockMovementInput.addEventListener("change", () =&gt; {&#10; settings.clockMovement = clockMovementInput.checked;&#10; if (!settings.clockMovement &amp;&amp; clockSpot) {&#10; clockSpot.vx = 0;&#10; clockSpot.vy = 0;&#10; }&#10; writeSettingsToUrl();&#10; });&#10;&#10; padSlider.addEventListener("input", () =&gt; {&#10; settings.padScale = Number(padSlider.value);&#10; buildPads();&#10; writeSettingsToUrl();&#10; });&#10;&#10; scaleSlider.addEventListener("input", () =&gt; {&#10; const v = Number(scaleSlider.value);&#10; settings.scaleOverride = v === 1 ? 0 : v;&#10; resize();&#10; buildPads();&#10; writeSettingsToUrl();&#10; });&#10;&#10; fishSlider.addEventListener("input", () =&gt; {&#10; settings.fishCap = Number(fishSlider.value);&#10; writeSettingsToUrl();&#10; });&#10;&#10; controls.addEventListener("pointerdown", (event) =&gt; event.stopPropagation());&#10;&#10; canvas.addEventListener("pointerdown", (event) =&gt; {&#10; const pos = pointerToPond(event);&#10; if (isClockHit(pos.x, pos.y)) {&#10; clockDragging = true;&#10; clockSpot.vx = 0;&#10; clockSpot.vy = 0;&#10; clockSpot.x = pos.x;&#10; clockSpot.y = pos.y;&#10; clampClockSpot();&#10; settings.clockX = clockSpot.x;&#10; settings.clockY = clockSpot.y;&#10; canvas.setPointerCapture(event.pointerId);&#10; event.preventDefault();&#10; return;&#10; }&#10; const x = clamp(pos.x, 20, W - 20);&#10; const y = clamp(pos.y, 20, H - 20);&#10; const now = performance.now();&#10; dropFeedAt(x, y, now);&#10; scheduleFeed(now);&#10; event.preventDefault();&#10; });&#10;&#10; canvas.addEventListener("pointermove", (event) =&gt; {&#10; if (!clockDragging || !clockSpot) return;&#10; const pos = pointerToPond(event);&#10; clockSpot.x = pos.x;&#10; clockSpot.y = pos.y;&#10; clockSpot.vx = 0;&#10; clockSpot.vy = 0;&#10; clampClockSpot();&#10; settings.clockX = clockSpot.x;&#10; settings.clockY = clockSpot.y;&#10; event.preventDefault();&#10; });&#10;&#10; function stopClockDrag(event) {&#10; if (!clockDragging) return;&#10; clockDragging = false;&#10; if (event.pointerId !== undefined &amp;&amp; canvas.hasPointerCapture(event.pointerId)) {&#10; canvas.releasePointerCapture(event.pointerId);&#10; }&#10; if (clockSpot) {&#10; settings.clockX = clockSpot.x;&#10; settings.clockY = clockSpot.y;&#10; writeSettingsToUrl();&#10; }&#10; }&#10;&#10; canvas.addEventListener("pointerup", stopClockDrag);&#10; canvas.addEventListener("pointercancel", stopClockDrag);&#10;&#10; requestAnimationFrame(frame);&#10;})();&#10;&lt;/script&gt;&#10;&lt;/body&gt;&#10;&lt;/html&gt;</description></item></channel></rss>