Ruisovergang met gloeirand
Click and a second image appears through a cloudy noise mask or in staggered strips, with an orange glowing edge at the boundary; shown here as a quay from day to evening. Good for day/night, before/after or two collections.
Havenkade, overdag
How to use it
- Paste the HTML where the backgrounds & webgl should appear.
- Add the CSS to your stylesheet. All classes are prefixed, so nothing clashes with your own styles.
- Add the JavaScript and call init() with the element that contains the HTML.
<!-- Ruisovergang met gloeirand · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="h4sr">
<canvas class="h4sr__c" role="img" aria-label="Havenkade overdag"></canvas>
<p class="h4sr__cap" aria-live="polite">Havenkade, overdag</p>
<div class="h4sr__ui">
<button class="h4sr__go" type="button">Toon de avond</button>
<div class="h4sr__mode" role="group" aria-label="Soort overgang">
<button class="h4sr__m" type="button" aria-pressed="true" data-m="ruis">Ruis</button>
<button class="h4sr__m" type="button" aria-pressed="false" data-m="stroken">Stroken</button>
</div>
</div>
</div>
</div>/* Ruisovergang met gloeirand · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.h4sr{position:absolute;inset:0;font-family:'Switzer',sans-serif;background:#f4f3f1;overflow:hidden}
.h4sr__c{position:absolute;inset:0;width:100%;height:100%;display:block}
.h4sr__cap{position:absolute;left:16px;top:12px;margin:0;font-size:clamp(14px,2vw,22px);font-weight:600;letter-spacing:-.01em;color:#0a0a0a;transition:color .6s}
.h4sr.is-night .h4sr__cap{color:#f4f3f1}
.h4sr__ui{position:absolute;left:12px;right:12px;bottom:12px;display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
.h4sr__go{min-height:32px;padding:0 14px;border:0;border-radius:4px;background:#F5480F;color:#fff;font:600 13px 'Switzer',sans-serif;cursor:pointer}
.h4sr__go:hover{background:#0a0a0a}
.h4sr.is-night .h4sr__go:hover{background:#fff;color:#0a0a0a}
.h4sr__mode{display:flex;background:#fff;border:1px solid #0a0a0a;border-radius:4px;overflow:hidden}
.h4sr__m{min-height:30px;padding:0 10px;border:0;background:none;color:#0a0a0a;font:500 13px 'Switzer',sans-serif;cursor:pointer}
.h4sr__m[aria-pressed=true]{background:#0a0a0a;color:#fff}
.h4sr__go:focus-visible,.h4sr__m:focus-visible{outline:2px solid #F5480F;outline-offset:2px}// Ruisovergang met gloeirand · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
var w=root.querySelector('.h4sr');if(!w)return;
var cv=w.querySelector('.h4sr__c'),ctx=cv.getContext('2d'),go=w.querySelector('.h4sr__go'),cap=w.querySelector('.h4sr__cap'),modes=[].slice.call(w.querySelectorAll('.h4sr__m'));
if(!ctx)return;
var reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
var dpr=Math.min(window.devicePixelRatio||1,2),W=0,H=0,day=null,night=null,tmp=null,mask=null,glow=null;
var GW=200,GH=125,fieldN=null,fieldS=null,mode='ruis',night_on=false,p=0,from=0,to=0,t0=0,raf=0;
function rnd(seed){var s=seed>>>0;return function(){s=(s*1664525+1013904223)>>>0;return s/4294967296;};}
function hash(x,y){var h=(x*374761393+y*668265263)>>>0;h=((h^(h>>>13))*1274126177)>>>0;return ((h^(h>>>16))>>>0)/4294967296;}
function vnoise(x,y){var xi=Math.floor(x),yi=Math.floor(y),xf=x-xi,yf=y-yi,u=xf*xf*(3-2*xf),v=yf*yf*(3-2*yf);
var a=hash(xi,yi),b=hash(xi+1,yi),c=hash(xi,yi+1),d=hash(xi+1,yi+1);return a+(b-a)*u+(c-a)*v+(a-b-c+d)*u*v;}
function fields(){
fieldN=new Float32Array(GW*GH);fieldS=new Float32Array(GW*GH);var mn=9,mx=-9,i,x,y;
for(y=0;y<GH;y++)for(x=0;x<GW;x++){var n=vnoise(x/24,y/24)*.6+vnoise(x/10,y/10)*.28+vnoise(x/4.2,y/4.2)*.12;fieldN[y*GW+x]=n;if(n<mn)mn=n;if(n>mx)mx=n;}
for(i=0;i<fieldN.length;i++)fieldN[i]=(fieldN[i]-mn)/(mx-mn);
var bands=9;for(y=0;y<GH;y++){var band=Math.floor(y/GH*bands),off=hash(band,7)*.3;for(x=0;x<GW;x++)fieldS[y*GW+x]=x/GW*.7+off;}
}
function scene(g,isNight){
var r=rnd(42);
var sky=g.createLinearGradient(0,0,0,H*.62);
if(isNight){sky.addColorStop(0,'#0a0a0a');sky.addColorStop(1,'#26211c');}else{sky.addColorStop(0,'#f4f3f1');sky.addColorStop(1,'#f3dccd');}
g.fillStyle=sky;g.fillRect(0,0,W,H);
var cx=W*.7,cy=H*.36,cr=Math.min(W,H)*.15;
if(isNight){g.fillStyle='#f4f3f1';g.beginPath();g.arc(cx,cy,cr*.55,0,6.2832);g.fill();g.fillStyle='#1b1815';g.beginPath();g.arc(cx+cr*.22,cy-cr*.12,cr*.5,0,6.2832);g.fill();
g.fillStyle='rgba(244,243,241,.7)';for(var s=0;s<40;s++){g.fillRect(r()*W,r()*H*.5,1.2,1.2);}}
else{g.fillStyle='#F5480F';g.beginPath();g.arc(cx,cy,cr,0,6.2832);g.fill();}
var q=H*.64;
g.fillStyle=isNight?'#171411':'#9e968c';
var bx=0;r=rnd(7);
while(bx<W){var bw=W*(.06+r()*.07),bh=H*(.08+r()*.12);g.fillRect(bx,q-bh,bw-2,bh);
if(isNight){g.fillStyle='#F5480F';for(var wy=q-bh+6;wy<q-6;wy+=9)for(var wx=bx+5;wx<bx+bw-8;wx+=8)if(r()<.35)g.fillRect(wx,wy,3.5,4);g.fillStyle='#171411';}
bx+=bw;}
g.strokeStyle=g.fillStyle=isNight?'#3b342d':'#0a0a0a';g.lineWidth=Math.max(2,W/260);
[[.18,.42],[.42,.34]].forEach(function(k){var mx=W*k[0],top=H*k[1];
g.fillRect(mx-W*.006,top,W*.012,q-top);g.fillRect(mx-W*.05,top,W*.2,W*.008);
g.beginPath();g.moveTo(mx+W*.12,top);g.lineTo(mx+W*.12,top+H*.12);g.stroke();
g.fillRect(mx+W*.105,top+H*.12,W*.03,H*.04);
if(isNight){g.fillStyle='#F5480F';g.fillRect(mx-W*.004,top-4,W*.008,4);g.fillStyle='#3b342d';}});
g.fillStyle=isNight?'#0f0d0b':'#d6cfc6';g.fillRect(0,q,W,H-q);
g.fillStyle=isNight?'rgba(245,72,15,.55)':'rgba(10,10,10,.12)';r=rnd(3);
for(var l=0;l<26;l++){var ly=q+8+r()*(H-q-16),lx=r()*W;g.fillRect(lx,ly,W*(.03+r()*.08),1.5);}
}
function canvas(){var c=document.createElement('canvas');return c;}
function resize(){
W=Math.max(1,w.clientWidth);H=Math.max(1,w.clientHeight);
cv.width=Math.round(W*dpr);cv.height=Math.round(H*dpr);
[day,night,tmp].forEach(function(c){c.width=cv.width;c.height=cv.height;});
var gd=day.getContext('2d'),gn=night.getContext('2d');gd.setTransform(dpr,0,0,dpr,0,0);gn.setTransform(dpr,0,0,dpr,0,0);
scene(gd,false);scene(gn,true);render();
}
var mdata,gdata;
function render(){
var A=night_on?(p<1?day:night):day,B=night;var lo=Math.min(from,to),field=mode==='ruis'?fieldN:fieldS;
var e=p*(1+2*.08)-.08,sft=.08,gl=Math.sin(Math.PI*p);
var md=mdata.data,gd=gdata.data;
for(var i=0;i<GW*GH;i++){
var f=field[i],a=(e-f)/sft;a=a<0?0:a>1?1:a;md[i*4+3]=a*255;
var gv=1-Math.abs(e-f)/(sft*1.1);gv=gv<0?0:gv*gv*gl;gd[i*4]=245;gd[i*4+1]=Math.round(72+90*gv*gv);gd[i*4+2]=15;gd[i*4+3]=Math.round(gv*210);
}
mask.getContext('2d').putImageData(mdata,0,0);glow.getContext('2d').putImageData(gdata,0,0);
ctx.setTransform(1,0,0,1,0,0);ctx.globalCompositeOperation='source-over';ctx.imageSmoothingEnabled=true;
ctx.drawImage(day,0,0);
var t=tmp.getContext('2d');t.globalCompositeOperation='source-over';t.clearRect(0,0,tmp.width,tmp.height);t.drawImage(night,0,0);
t.globalCompositeOperation='destination-in';t.imageSmoothingEnabled=true;t.drawImage(mask,0,0,tmp.width,tmp.height);t.globalCompositeOperation='source-over';
ctx.drawImage(tmp,0,0);
if(gl>0.001){ctx.drawImage(glow,0,0,cv.width,cv.height);}
}
function ease(x){return x<.5?4*x*x*x:1-Math.pow(-2*x+2,3)/2;}
function anim(t){
if(!t0)t0=t;var k=Math.min(1,(t-t0)/1500);p=from+(to-from)*ease(k);render();
raf=k<1?requestAnimationFrame(anim):0;
}
function flip(){
night_on=!night_on;from=p;to=night_on?1:0;
w.classList.toggle('is-night',night_on);
go.textContent=night_on?'Toon de dag':'Toon de avond';
cap.textContent=night_on?'Havenkade, in de avond':'Havenkade, overdag';cv.setAttribute('aria-label',cap.textContent);
cancelAnimationFrame(raf);t0=0;
if(reduce){p=to;render();return;}
raf=requestAnimationFrame(anim);
}
day=canvas();night=canvas();tmp=canvas();mask=canvas();glow=canvas();mask.width=glow.width=GW;mask.height=glow.height=GH;
mdata=mask.getContext('2d').createImageData(GW,GH);gdata=glow.getContext('2d').createImageData(GW,GH);
fields();
go.addEventListener('click',flip);
modes.forEach(function(b){b.addEventListener('click',function(){mode=b.getAttribute('data-m');modes.forEach(function(x){x.setAttribute('aria-pressed',x===b?'true':'false');});});});
resize();
if('ResizeObserver' in window)new ResizeObserver(function(){if(Math.abs(w.clientWidth-W)>1||Math.abs(w.clientHeight-H)>1)resize();}).observe(w);
}
init(document.querySelector('.jouw-container'));
More backgrounds & webgl
Seen something you like?
Add it to your selection and send it over. We build your site around it, in your brand.
Get in touch →