WebGL fluid cursor
Fluid simulation · WebGL fluid · Ink cursor · Scia d'inchiostro · Simulación de fluidos · Fluid cursor trail
Moving the mouse across the page leaves a trail of coloured ink that mixes, swirls and fades as if in a water tank. It is a fluid simulation running in the browser tab, used as a living background on creative sites.
- Era
- 2017 – today
- Origin
- Creative coding sul web
- Use
- Niche
Live demo
View code
<canvas></canvas><h1>Muovi<br>l'inchiostro</h1>
<script>
const c=document.querySelector('canvas'),x=c.getContext('2d');let W,H,t=0,mx=null,my=null,pts=[];const red=!matchMedia('(prefers-reduced-motion: no-preference)').matches;
const rs=()=>{W=c.width=innerWidth;H=c.height=innerHeight;x.fillStyle='#000';x.fillRect(0,0,W,H)};rs();addEventListener('resize',rs);addEventListener('pointermove',e=>{mx=e.clientX;my=e.clientY});
const cols=['255,45,149','0,229,255','255,230,0','122,0,255'];
const go=()=>{t+=.02;x.globalCompositeOperation='source-over';x.fillStyle='rgba(0,0,0,.09)';x.fillRect(0,0,W,H);
const px=mx??W/2+Math.sin(t)*W*.35+Math.sin(t*2.3)*40,py=my??H/2+Math.sin(t*1.4)*H*.3;
for(let k=0;k<3;k++)pts.push({x:px,y:py,vx:(Math.random()-.5)*2+Math.cos(t*3)*2,vy:(Math.random()-.5)*2+Math.sin(t*3)*2,r:18+Math.random()*20,c:cols[(t*.6+k)%4|0],a:.16});
x.globalCompositeOperation='lighter';pts=pts.filter(p=>p.a>.02);for(const p of pts){p.x+=p.vx+Math.sin(p.y*.02+t)*1.2;p.y+=p.vy+Math.cos(p.x*.02+t)*1.2;p.r*=1.015;p.a*=.965;const g=x.createRadialGradient(p.x,p.y,0,p.x,p.y,p.r);g.addColorStop(0,`rgba(${p.c},${p.a})`);g.addColorStop(1,`rgba(${p.c},0)`);x.fillStyle=g;x.beginPath();x.arc(p.x,p.y,p.r,0,7);x.fill()}
if(!red)requestAnimationFrame(go)};if(red){const g=x.createLinearGradient(0,0,W,H);g.addColorStop(0,'#7A00FF');g.addColorStop(1,'#FF2D95');x.fillStyle=g;x.fillRect(0,0,W,H)}else go();
</script> body{background:#000;overflow:hidden;display:grid;place-items:center}
canvas{position:fixed;inset:0;width:100%;height:100%}
h1{position:relative;margin:0;font:800 56px/0.95 Syne,sans-serif;color:#fff;text-align:center;mix-blend-mode:difference;pointer-events:none} Characteristics
- Coloured trail following and spreading from the cursor
- Realistic swirls and colour mixing
- Saturated colours fading into black
- Motion carrying on by inertia after the gesture
- Often behind a big white headline
Palette
Click a swatch to copy it
Typography
Headings · Syne WebGL fluid cursor
Body · Inter Moving the mouse across the page leaves a trail of coloured ink that mixes, swirls and fades as if in a water tank. It is a fluid simulation running in the browser tab, used as a living background on creative sites.
Motion
- Easing
fisica dei fluidi (Navier-Stokes), dissipazione 0.97–0.99- Typical duration
- continua; la scia sfuma in 1–3 s
- Techniques
- WebGL fragment shader, simulazione stable fluids, ping-pong framebuffer, librerie come WebGL-Fluid-Simulation
Accessibility (reduced motion)
No simulation; a static gradient in the same colours remains.
Prompt for your agent
Copy and paste into your prompt to have an agent or image generator reproduce this style.
For web pages and UI
Design the web page or interface in this style: WebGL fluid cursor (Fluid simulation, WebGL fluid). Moving the mouse across the page leaves a trail of coloured ink that mixes, swirls and fades as if in a water tank. It is a fluid simulation running in the browser tab, used as a living background on creative sites. Characteristics: Coloured trail following and spreading from the cursor, Realistic swirls and colour mixing, Saturated colours fading into black, Motion carrying on by inertia after the gesture, Often behind a big white headline. Palette: #000000, #FF2D95, #00E5FF, #FFE600, #7A00FF. Typography: headings in Syne, body text in Inter (Google Fonts or equivalents). Mood: immersive, dreamy, energetic. Motion: easing fisica dei fluidi (Navier-Stokes), dissipazione 0.97–0.99, typical duration continua; la scia sfuma in 1–3 s; techniques: WebGL fragment shader, simulazione stable fluids, ping-pong framebuffer, librerie come WebGL-Fluid-Simulation. With prefers-reduced-motion: No simulation; a static gradient in the same colours remains. References: WebGL Fluid Simulation di Pavel Dobryakov (2017), Stable Fluids (1999), Siti creativi su Awwwards.
Relations
Derives from
Similar to
Contrasts with
References
- WebGL Fluid Simulation di Pavel Dobryakov (2017)
- Stable Fluids (1999)
- Siti creativi su Awwwards