Puntenveld met golf
A grid of dots that breathes gently and swells in waves around your cursor; a click sends a shockwave through the field. Runs on WebGL with a canvas fallback; for a technical hero or a data section.
Beweeg of klik in het veld
How to use it
- Paste the HTML where the backgrounds & webgl should appear. Include the script tags at the top once per page.
- 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.
<!-- Puntenveld met golf · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<!-- benodigd, één keer per pagina: -->
<script type="module">import * as OGL from "https://esm.sh/ogl@1.0.11"; window.OGL = OGL;</script>
<div class="jouw-container">
<div class="h4dw"><canvas class="h4dw__c" aria-hidden="true"></canvas><p class="h4dw__hint">Beweeg of klik in het veld</p></div>
</div>/* Puntenveld met golf · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
.h4dw{position:absolute;inset:0;background:#0a0a0a;overflow:hidden;cursor:crosshair;touch-action:pan-y}
.h4dw__c{position:absolute;inset:0;width:100%;height:100%;display:block}
.h4dw__hint{position:absolute;left:14px;bottom:10px;margin:0;font:500 12px 'Switzer',sans-serif;color:rgba(244,243,241,.6);pointer-events:none}// Puntenveld met golf · © 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('.h4dw');if(!w)return;
var cv=w.querySelector('.h4dw__c');
var reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
var GAP=16,SIZE=3,dpr=Math.min(window.devicePixelRatio||1,2);
var W=0,H=0,pts=null,count=0;
var mouse={x:-9999,y:-9999},aim={x:-9999,y:-9999},hover=0,hoverAim=0,click={x:0,y:0,t:99},time=0,last=0,raf=0,vis=true;
function grid(){
var cols=Math.ceil(W/GAP)+1,rows=Math.ceil(H/GAP)+1,ox=(W-(cols-1)*GAP)/2,oy=(H-(rows-1)*GAP)/2;
pts=new Float32Array(cols*rows*2);count=cols*rows;var k=0;
for(var y=0;y<rows;y++)for(var x=0;x<cols;x++){pts[k++]=ox+x*GAP;pts[k++]=oy+y*GAP;}
}
/* ---- WebGL via OGL ---- */
var gl=null,ren=null,prog=null,mesh=null;
var VS=['attribute vec2 position;','uniform vec2 uRes;uniform vec2 uMouse;uniform float uTime;uniform float uHover;uniform vec2 uClick;uniform float uClickT;uniform float uSize;uniform float uDpr;','varying float vH;',
'void main(){','vec2 p=position;vec2 d=p-uMouse;float dist=length(d);',
'float wave=sin(dist*0.05-uTime*3.4)*exp(-dist*0.009)*uHover;',
'float idle=sin(p.x*0.018+uTime*0.8)*cos(p.y*0.022+uTime*0.6)*0.22;',
'vec2 c=p-uClick;float cd=length(c);float front=uClickT*320.0;',
'float shock=exp(-abs(cd-front)*0.035)*exp(-uClickT*1.6);',
'float h=wave+idle+shock*1.4;',
'vec2 dir=dist>0.001?d/dist:vec2(0.0);vec2 cdir=cd>0.001?c/cd:vec2(0.0);',
'p+=dir*wave*5.0+cdir*shock*7.0;vH=h;',
'vec2 cl=p/uRes*2.0-1.0;gl_Position=vec4(cl.x,-cl.y,0.0,1.0);',
'gl_PointSize=(uSize+max(h,0.0)*uSize*1.5)*uDpr;}'].join(' ');
var FS=['precision mediump float;varying float vH;','void main(){vec2 c=gl_PointCoord-0.5;if(dot(c,c)>0.25)discard;',
'vec3 base=vec3(0.42,0.40,0.38);vec3 hot=vec3(0.961,0.282,0.059);vec3 top=vec3(0.957,0.953,0.945);',
'float k=clamp(vH*0.85+0.1,0.0,1.0);vec3 col=mix(base,hot,k);col=mix(col,top,clamp(vH-1.1,0.0,1.0)*0.6);',
'gl_FragColor=vec4(col,1.0);}'].join(' ');
function initGL(){
if(!window.OGL)return false;
try{
ren=new OGL.Renderer({canvas:cv,dpr:dpr,alpha:true,antialias:false});gl=ren.gl;if(!gl)return false;
gl.clearColor(0,0,0,0);
prog=new OGL.Program(gl,{vertex:VS,fragment:FS,uniforms:{uRes:{value:[1,1]},uMouse:{value:[-9999,-9999]},uTime:{value:0},uHover:{value:0},uClick:{value:[0,0]},uClickT:{value:99},uSize:{value:SIZE},uDpr:{value:dpr}}});
return true;
}catch(e){gl=null;return false;}
}
function buildGL(){
ren.setSize(W,H);
var geo=new OGL.Geometry(gl,{position:{size:2,data:pts}});
if(mesh&&mesh.geometry&&mesh.geometry.remove)mesh.geometry.remove();
mesh=new OGL.Mesh(gl,{mode:gl.POINTS,geometry:geo,program:prog});
prog.uniforms.uRes.value=[W,H];
}
function drawGL(){
var u=prog.uniforms;u.uMouse.value=[mouse.x,mouse.y];u.uTime.value=time;u.uHover.value=hover;u.uClick.value=[click.x,click.y];u.uClickT.value=click.t;
ren.render({scene:mesh});
}
/* ---- terugval: canvas 2D met dezelfde formule ---- */
var c2=null;
function draw2D(){
c2.setTransform(dpr,0,0,dpr,0,0);c2.clearRect(0,0,W,H);
for(var i=0;i<count;i++){
var x=pts[i*2],y=pts[i*2+1],dx=x-mouse.x,dy=y-mouse.y,dist=Math.sqrt(dx*dx+dy*dy);
var wave=Math.sin(dist*0.05-time*3.4)*Math.exp(-dist*0.009)*hover;
var idle=Math.sin(x*0.018+time*0.8)*Math.cos(y*0.022+time*0.6)*0.22;
var cx=x-click.x,cy=y-click.y,cd=Math.sqrt(cx*cx+cy*cy),shock=Math.exp(-Math.abs(cd-click.t*320)*0.035)*Math.exp(-click.t*1.6);
var h=wave+idle+shock*1.4;
if(dist>0.001){x+=dx/dist*wave*5;y+=dy/dist*wave*5;}
if(cd>0.001){x+=cx/cd*shock*7;y+=cy/cd*shock*7;}
var k=Math.max(0,Math.min(1,h*0.85+0.1)),r=(SIZE+Math.max(h,0)*SIZE*1.5)/2;
c2.fillStyle='rgb('+Math.round(107+(245-107)*k)+','+Math.round(102+(72-102)*k)+','+Math.round(97+(15-97)*k)+')';
c2.beginPath();c2.arc(x,y,r,0,6.2832);c2.fill();
}
}
var useGL=initGL();
if(!useGL){c2=cv.getContext('2d');}
function resize(){
W=Math.max(1,w.clientWidth);H=Math.max(1,w.clientHeight);grid();
if(useGL)buildGL();else{cv.width=Math.round(W*dpr);cv.height=Math.round(H*dpr);}
if(reduce||!raf)render();
}
function render(){if(useGL)drawGL();else if(c2)draw2D();}
function frame(t){
var dt=last?Math.min((t-last)/1000,0.05):0;last=t;
time+=dt;click.t+=dt;
hover+=(hoverAim-hover)*(1-Math.exp(-dt/0.25));
mouse.x+=(aim.x-mouse.x)*(1-Math.exp(-dt/0.08));mouse.y+=(aim.y-mouse.y)*(1-Math.exp(-dt/0.08));
render();
raf=vis?requestAnimationFrame(frame):0;if(!raf)last=0;
}
function pos(e){var r=w.getBoundingClientRect();return {x:e.clientX-r.left,y:e.clientY-r.top};}
w.addEventListener('pointermove',function(e){var p=pos(e);aim.x=p.x;aim.y=p.y;if(hoverAim===0){mouse.x=p.x;mouse.y=p.y;}hoverAim=1;if(reduce){mouse.x=p.x;mouse.y=p.y;hover=1;render();}});
w.addEventListener('pointerleave',function(){hoverAim=0;if(reduce){hover=0;render();}});
w.addEventListener('pointerdown',function(e){if(reduce)return;var p=pos(e);click.x=p.x;click.y=p.y;click.t=0;});
resize();
if('ResizeObserver' in window)new ResizeObserver(resize).observe(w);
if(!reduce){
if('IntersectionObserver' in window)new IntersectionObserver(function(es){vis=es[0].isIntersecting;if(vis&&!raf)raf=requestAnimationFrame(frame);}).observe(w);
raf=requestAnimationFrame(frame);
}
}
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 →