Condensation Droplets
Mist, droplets and rain on glass generated from seeded random circles, with a density slider.
AI prompt
Close-up photograph of a window pane covered in water droplets after rain, round beads of different sizes each with a small bright highlight and a darker rim, a blurred warm city of lights behind the glass, soft bokeh, cool blue-grey tones with orange glow, shallow depth of field, moody and calm. Variants: fine mist of tiny droplets, large sparse drops with a few running streaks. Negative: cartoon bubbles, uniform dots, text, heavy fog hiding the background, hands. Reduced motion: static image.About this pattern
Definition
Water on glass shows up as many small round lenses. Each drop is a circle with a bright highlight at the top, a darker rim and a soft shadow; scattered at different sizes they read instantly as wet glass.
Purpose & UX principles
- Each drop: radial gradient with a small white highlight, a mid tone that is almost transparent and a darker edge.
- Vary size widely and keep a few tiny ones between big ones.
- Use a fixed random seed so the layout is stable between loads.
Interaction states
- Three types (Mist, Droplets, Rain) and a Density slider.
Motion specification
- Drops fade in over 300ms when the settings change.
- Reduced motion: drops appear without fading.
Responsive behaviour
- Many small elements cost performance; keep the count under about 150.
- Never put readable text under dense drops.
Code
<div class="bx"><div class="gl" id="gl"></div><div class="pre" id="pre" role="group" aria-label="Type"><button data-p="0" aria-pressed="true">Mist</button><button data-p="1" aria-pressed="false">Droplets</button><button data-p="2" aria-pressed="false">Rain</button></div><label class="rw">Density <b id="dv">60</b><input id="dn" type="range" min="10" max="150" value="60"></label></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.gl{height:132px;border-radius:12px;position:relative;overflow:hidden;background:radial-gradient(circle at 25% 40%,#f2a65a 0,transparent 30%),radial-gradient(circle at 70% 60%,#6a8cff 0,transparent 35%),linear-gradient(#2a3347,#1b2030)}
.gl i{position:absolute;display:block;border-radius:50%;background:radial-gradient(circle at 35% 28%,rgba(255,255,255,.95) 0 9%,rgba(255,255,255,.12) 32%,rgba(0,0,0,.28) 100%);box-shadow:0 2px 3px rgba(0,0,0,.35);animation:fi .3s both}
@keyframes fi{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){.gl i{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const T=[[3,8,150],[6,18,60],[10,24,25]],gl=document.getElementById('gl'),dn=document.getElementById('dn'),bs=[...document.querySelectorAll('#pre button')];let p=1;
let sd=11;const rnd=()=>(sd=(sd*16807)%2147483647)/2147483647;
function up(){gl.innerHTML='';sd=11;const [a,b]=T[p],n=+dn.value,w=gl.clientWidth,h=gl.clientHeight;for(let i=0;i<n;i++){const s=a+Math.pow(rnd(),2.2)*(b-a),e=document.createElement('i');e.style.cssText='width:'+s+'px;height:'+s+'px;left:'+(rnd()*(w-s))+'px;top:'+(rnd()*(h-s))+'px';gl.appendChild(e);}document.getElementById('dv').textContent=n;bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;dn.value=[130,60,25][p];up();}));dn.addEventListener('input',up);dn.value=60;up();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Condensation Droplets — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.gl{height:132px;border-radius:12px;position:relative;overflow:hidden;background:radial-gradient(circle at 25% 40%,#f2a65a 0,transparent 30%),radial-gradient(circle at 70% 60%,#6a8cff 0,transparent 35%),linear-gradient(#2a3347,#1b2030)}
.gl i{position:absolute;display:block;border-radius:50%;background:radial-gradient(circle at 35% 28%,rgba(255,255,255,.95) 0 9%,rgba(255,255,255,.12) 32%,rgba(0,0,0,.28) 100%);box-shadow:0 2px 3px rgba(0,0,0,.35);animation:fi .3s both}
@keyframes fi{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){.gl i{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="gl" id="gl"></div><div class="pre" id="pre" role="group" aria-label="Type"><button data-p="0" aria-pressed="true">Mist</button><button data-p="1" aria-pressed="false">Droplets</button><button data-p="2" aria-pressed="false">Rain</button></div><label class="rw">Density <b id="dv">60</b><input id="dn" type="range" min="10" max="150" value="60"></label></div>
</div>
<script>
const T=[[3,8,150],[6,18,60],[10,24,25]],gl=document.getElementById('gl'),dn=document.getElementById('dn'),bs=[...document.querySelectorAll('#pre button')];let p=1;
let sd=11;const rnd=()=>(sd=(sd*16807)%2147483647)/2147483647;
function up(){gl.innerHTML='';sd=11;const [a,b]=T[p],n=+dn.value,w=gl.clientWidth,h=gl.clientHeight;for(let i=0;i<n;i++){const s=a+Math.pow(rnd(),2.2)*(b-a),e=document.createElement('i');e.style.cssText='width:'+s+'px;height:'+s+'px;left:'+(rnd()*(w-s))+'px;top:'+(rnd()*(h-s))+'px';gl.appendChild(e);}document.getElementById('dv').textContent=n;bs.forEach(b=>b.setAttribute('aria-pressed',String(+b.dataset.p===p)));}
bs.forEach(b=>b.addEventListener('click',()=>{p=+b.dataset.p;dn.value=[130,60,25][p];up();}));dn.addEventListener('input',up);dn.value=60;up();
</script>
</body></html>