Liquid Metal Captcha
A human check that solves itself: a drop of liquid metal jumps into the checkbox, draws the tick, then goes through the traffic lights test on its own and comes back as a big green tick.
- Sign in & forms
- Free
- webgl
- captcha
- liquid-metal
- Added Oct 4, 2026
<style>
/* Liquid Metal Captcha by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */
.lmc {
--accent: #6BEBD9;
--ok: #63F2A0;
position: relative;
width: 284px;
margin-top: max(40px, calc(50vh - 245px));
}
.lmc canvas {
position: absolute;
left: -70px;
top: -70px;
z-index: 3;
width: 424px;
height: 620px;
pointer-events: none;
}
.lmc .row, .lmc .task {
position: relative;
border-radius: 16px;
background: linear-gradient(#151923, #10131B);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 0 0 1px rgba(255, 255, 255, .06), 0 24px 50px -22px rgba(0, 0, 0, .85);
}
.lmc .row { display: flex; align-items: center; gap: 13px; height: 70px; padding: 0 12px 0 18px; box-sizing: border-box; }
.lmc .box {
width: 34px;
height: 34px;
flex: none;
padding: 0;
border: 1.5px solid #3B4150;
border-radius: 9px;
background: #0A0C12;
cursor: pointer;
transition: border-color .2s ease, box-shadow .2s ease;
}
.lmc button:focus-visible { outline: 3px solid rgba(107, 235, 217, .45); outline-offset: 2px; }
.lmc.ok .box { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(99, 242, 160, .14); }
.lmc .say { font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.lmc .home { position: absolute; right: 12px; top: 0; width: 62px; height: 100%; box-sizing: border-box; padding-top: 50px; text-align: center; color: #6B7282; font-size: 9px; letter-spacing: .05em; white-space: nowrap; transition: opacity .2s ease-out; }
.lmc.ok .home { opacity: 0; }
.lmc .task {
height: 0;
margin-top: 8px;
overflow: hidden;
opacity: 0;
transition: height .42s cubic-bezier(.32, .72, 0, 1), opacity .25s ease-out;
}
.lmc.open .task { opacity: 1; }
.lmc .head { padding: 11px 16px 10px; background: linear-gradient(#123235, #0E2628); }
.lmc .head small { display: block; color: #A9D8D2; font-size: 12px; }
.lmc .head b { color: #fff; font-size: 20px; letter-spacing: -.01em; }
.lmc .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; }
.lmc .tile {
display: block;
width: 100%;
aspect-ratio: 1;
padding: 0;
border: 0;
border-radius: 8px;
overflow: hidden;
background: #0B0D13;
outline: 3px solid transparent;
outline-offset: -3px;
cursor: pointer;
transition: scale .16s ease-out;
}
.lmc .tile svg { display: block; width: 100%; height: 100%; }
.lmc .tile.picked { scale: .93; }
.lmc.still .tile.picked { outline-color: var(--accent); }
.lmc .lamp { transition: fill .16s ease-out; }
.lmc .lamp.r { fill: #4B1B17; }
.lmc .lamp.y { fill: #4A3D14; }
.lmc .lamp.g { fill: #14432A; }
.lmc .lamp.r.on { fill: #FF5142; filter: drop-shadow(0 0 5px #FF5142); }
.lmc .lamp.y.on { fill: #FFC83D; filter: drop-shadow(0 0 5px #FFC83D); }
.lmc .lamp.g.on { fill: #3DFF8A; filter: drop-shadow(0 0 5px #3DFF8A); }
.lmc .foot { display: flex; align-items: center; padding: 0 8px 8px 14px; }
.lmc .nest { width: 40px; height: 34px; }
.lmc .verify {
height: 34px;
margin-left: auto;
padding: 0 18px;
border: 0;
border-radius: 9px;
background: var(--accent);
color: #062321;
font: 700 13px system-ui, sans-serif;
cursor: pointer;
}
.lmc.still.ok .box { background: var(--ok); }
</style>
<!-- EFFECT -->
<div class="lmc" id="lmc">
<svg width="0" height="0" style="position:absolute" aria-hidden="true"><defs>
<linearGradient id="lmc-dusk" x2="0" y2="1"><stop offset="0" stop-color="#1B2140"/><stop offset=".58" stop-color="#3D2B55"/><stop offset="1" stop-color="#B95B3A"/></linearGradient>
<linearGradient id="lmc-night" x2="0" y2="1"><stop offset="0" stop-color="#0B1024"/><stop offset=".6" stop-color="#1B2248"/><stop offset="1" stop-color="#2E2D52"/></linearGradient>
<linearGradient id="lmc-teal" x2="0" y2="1"><stop offset="0" stop-color="#0C1B26"/><stop offset=".6" stop-color="#13363D"/><stop offset="1" stop-color="#2B5A55"/></linearGradient>
<filter id="lmc-soft" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="3.2"/></filter>
</defs></svg>
<canvas aria-hidden="true"></canvas>
<div class="row">
<button class="box" type="button" role="checkbox" aria-checked="false" aria-label="I'm not a robot"></button>
<span class="say" aria-live="polite">I'm not a robot</span>
<span class="home">human check</span>
</div>
<div class="task" inert>
<div class="head"><small>Select all squares with</small><b>traffic lights</b></div>
<div class="grid">
<button class="tile" type="button" aria-pressed="false" aria-label="street lamp"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><circle cx="70" cy="27" r="17" fill="#FFC870" opacity="0.55" filter="url(#lmc-soft)"/><path d="M30 100V36c0-12 8-19 20-19h13" stroke="#07080B" stroke-width="5" fill="none" stroke-linecap="round"/><rect x="59" y="12" width="22" height="8" rx="3" fill="#07080B"/><ellipse cx="70" cy="21" rx="7.5" ry="2.4" fill="#FFE6B0"/></svg></button>
<button class="tile light" type="button" aria-pressed="false" aria-label="traffic light"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><circle cx="18" cy="30" r="9" fill="#7C8CFF" opacity="0.35" filter="url(#lmc-soft)"/><circle cx="84" cy="62" r="11" fill="#FF9A5C" opacity="0.3" filter="url(#lmc-soft)"/><rect x="46.5" y="66" width="7" height="34" fill="#06070A"/><rect x="34" y="14" width="32" height="60" rx="8" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="50" cy="28" r="7.2"/><circle class="lamp y" cx="50" cy="44" r="7.2"/><circle class="lamp g" cx="50" cy="60" r="7.2"/></svg></button>
<button class="tile" type="button" aria-pressed="false" aria-label="car"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><rect y="72" width="100" height="28" fill="#090A0E"/><circle cx="26" cy="63" r="9" fill="#FF4638" opacity="0.7" filter="url(#lmc-soft)"/><circle cx="74" cy="63" r="9" fill="#FF4638" opacity="0.7" filter="url(#lmc-soft)"/><path d="M16 76V61c0-4 3-7 7-8l8-13c2-3 5-5 9-5h20c4 0 7 2 9 5l8 13c4 1 7 4 7 8v15z" fill="#10131A"/><path d="M33 53l6-10c1-2 3-3 5-3h12c2 0 4 1 5 3l6 10z" fill="#27344A"/><rect x="21" y="60" width="13" height="6" rx="2" fill="#FF4638"/><rect x="66" y="60" width="13" height="6" rx="2" fill="#FF4638"/><rect x="22" y="76" width="12" height="9" rx="3" fill="#050608"/><rect x="66" y="76" width="12" height="9" rx="3" fill="#050608"/></svg></button>
<button class="tile" type="button" aria-pressed="false" aria-label="bicycle"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><rect y="84" width="100" height="16" fill="#0A0B0F"/><g fill="none" stroke="#07080B" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="29" cy="70" r="14"/><circle cx="71" cy="70" r="14"/><path d="M29 70l13-25h20l9 25M42 45l12 25H29M62 45l-8 25M38 40h9M60 38h8"/></g></svg></button>
<button class="tile" type="button" aria-pressed="false" aria-label="lit windows"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><rect x="14" y="8" width="72" height="92" fill="#0B0D14"/><rect x="22" y="16" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="16" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="16" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="16" width="9" height="10" rx="1" fill="#161A26"/><rect x="22" y="32" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="32" width="9" height="10" rx="1" fill="#161A26"/><rect x="52" y="32" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="32" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="22" y="48" width="9" height="10" rx="1" fill="#161A26"/><rect x="37" y="48" width="9" height="10" rx="1" fill="#161A26"/><rect x="52" y="48" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="67" y="48" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="22" y="64" width="9" height="10" rx="1" fill="#161A26"/><rect x="37" y="64" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="64" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="67" y="64" width="9" height="10" rx="1" fill="#161A26"/><rect x="22" y="80" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="80" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="80" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="80" width="9" height="10" rx="1" fill="#FFD27A"/></svg></button>
<button class="tile light" type="button" aria-pressed="false" aria-label="edge of a traffic light"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><circle cx="66" cy="72" r="12" fill="#6BEBD9" opacity="0.22" filter="url(#lmc-soft)"/><path d="M86 100V24H22" stroke="#06070A" stroke-width="5" fill="none" stroke-linecap="round" stroke-linejoin="round"/><rect x="-4" y="4" width="26" height="50" rx="6" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="9" cy="16" r="5.2"/><circle class="lamp y" cx="9" cy="29" r="5.2"/><circle class="lamp g" cx="9" cy="42" r="5.2"/><path d="M0 92h100" stroke="#1A2A2E" stroke-width="2"/></svg></button>
<button class="tile light" type="button" aria-pressed="false" aria-label="traffic light over the street"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><path d="M0 100V70h12V58h10v12h8V50h12v20h10v30z" fill="#0A0B10"/><rect x="69" y="70" width="6" height="30" fill="#06070A"/><rect x="58" y="16" width="28" height="56" rx="7" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="72" cy="30" r="6.6"/><circle class="lamp y" cx="72" cy="44" r="6.6"/><circle class="lamp g" cx="72" cy="58" r="6.6"/></svg></button>
<button class="tile" type="button" aria-pressed="false" aria-label="crosswalk"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><path d="M0 100L30 52h40l30 48z" fill="#0A0B10"/><path d="M30.0 56.0h40.0l2.6 4.6H27.4z" fill="#D9DDE8" opacity=".82"/><path d="M22.6 65.4h54.8l2.6 4.6H20.0z" fill="#D9DDE8" opacity=".82"/><path d="M15.2 74.8h69.6l2.6 4.6H12.6z" fill="#D9DDE8" opacity=".82"/><path d="M7.8 84.2h84.4l2.6 4.6H5.2z" fill="#D9DDE8" opacity=".82"/><path d="M0.4 93.6h99.2l2.6 4.6H-2.2z" fill="#D9DDE8" opacity=".82"/></svg></button>
<button class="tile" type="button" aria-pressed="false" aria-label="fire hydrant"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><rect y="82" width="100" height="18" fill="#0A0B0F"/><g fill="#D8452F"><rect x="40" y="46" width="20" height="38" rx="4"/><path d="M38 47h24l-3-9H41z"/><circle cx="50" cy="36" r="5"/><rect x="31" y="54" width="10" height="9" rx="2.5"/><rect x="59" y="54" width="10" height="9" rx="2.5"/><rect x="36" y="82" width="28" height="5" rx="2"/></g><rect x="44" y="52" width="4" height="26" rx="2" fill="#F07A5E" opacity=".6"/></svg></button>
</div>
<div class="foot"><span class="nest"></span><button class="verify" type="button">Verify</button></div>
</div>
</div>
<!-- /EFFECT -->
<script>
/* Liquid Metal Captcha by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */
(() => {
const MELT = 20;
const SPRING = 260;
const DAMP = 22;
const PICK = 0.5;
async function checkHuman() {
// run your real check here and return true when the visitor passed
return true;
}
const root = document.getElementById('lmc'), cv = root.querySelector('canvas');
const box = root.querySelector('.box'), say = root.querySelector('.say'), home = root.querySelector('.home');
const task = root.querySelector('.task'), grid = root.querySelector('.grid'), nest = root.querySelector('.nest'), button = root.querySelector('.verify');
const tiles = [...root.querySelectorAll('.tile')];
const lights = tiles.filter(t => t.classList.contains('light'));
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
for (const tile of tiles) { tile.light = lights.includes(tile); tile.on = false; }
const TICK = [[-9, 1], [-3, 8], [10.5, -8]];
const W = 424, H = 620, BIG = 19;
const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
const lerp = (a, b, k) => a + (b - a) * k;
const out = k => 1 - (1 - k) ** 3;
const wait = s => new Promise(done => setTimeout(done, s * 1000));
function tween(sec, fn, ease = out) {
return new Promise(done => {
const t0 = performance.now();
requestAnimationFrame(function tick(now) {
const k = clamp((now - t0) / (sec * 1000));
fn(ease(k));
if (k < 1) requestAnimationFrame(tick); else done();
});
});
}
// the middle of an element, measured from the corner of the canvas
function centre(el) {
const r = el.getBoundingClientRect(), c = cv.getBoundingClientRect();
return { x: r.left - c.left + r.width / 2, y: r.top - c.top + r.height / 2, half: r.width / 2 };
}
const isOpen = () => root.classList.contains('open');
const drop = { x: 0, y: 0, vx: 0, vy: 0, tx: 0, ty: 0, r: BIG };
const tail = { x: 0, y: 0 }, tip = { x: 0, y: 0 };
const tick = { k: 0, size: 1 };
const rings = lights.map(() => ({ x: 0, y: 0, half: 0, w: 0, lit: 0 }));
lights.forEach((tile, i) => { tile.ring = rings[i]; });
let win = 0, heat = .8, busy = false, done = false, pointer = null, clock = 0;
const FS = `#version 300 es
precision highp float;
uniform vec3 BALL[3], KEY;
uniform vec4 SEG[2], RING[3], LAMP[3];
uniform vec2 SEGR, RES;
uniform float MELT, SCALE, win;
out vec4 o;
const vec3 VIEW = vec3(0., 0., 1.), TINT = vec3(.5, 1., .72), ACCENT = vec3(.42, .92, .85);
float box(vec2 p, float b, float r) {
vec2 q = abs(p) - b + r;
return min(max(q.x, q.y), 0.) + length(max(q, 0.)) - r;
}
float seg(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
return length(pa - ba * clamp(dot(pa, ba) / max(dot(ba, ba), 1e-4), 0., 1.));
}
vec2 smin(vec2 a, vec2 b, float k) {
float h = clamp(.5 + .5 * (b.x - a.x) / k, 0., 1.);
return vec2(mix(b.x, a.x, h) - k * h * (1. - h), mix(b.y, a.y, h));
}
vec2 shape(vec2 p) {
vec2 d = vec2(1e4, 1.);
for (int i = 0; i < 3; i++) if (BALL[i].z > 0.) d = smin(d, vec2(length(p - BALL[i].xy) - BALL[i].z, BALL[i].z), MELT);
for (int i = 0; i < 2; i++) if (SEGR[i] > 0.) d = smin(d, vec2(seg(p, SEG[i].xy, SEG[i].zw) - SEGR[i], SEGR[i]), MELT * .18);
for (int i = 0; i < 3; i++) if (RING[i].w > 0.) d = smin(d, vec2(abs(box(p - RING[i].xy, RING[i].z, 9.)) - RING[i].w, RING[i].w), MELT * .5);
return d;
}
vec3 normal(vec2 p, float s) {
vec2 e = vec2(.4, 0.);
vec2 g = vec2(shape(p + e.xy).x - shape(p - e.xy).x, shape(p + e.yx).x - shape(p - e.yx).x);
float slope = min((1. - s) / sqrt(max(1. - (1. - s) * (1. - s), 1e-4)), 14.);
return normalize(vec3(normalize(g + 1e-6) * slope, 1.));
}
float fresnel(float c) { return mix(.8, 1., pow(1. - c, 5.)); }
vec3 env(vec3 r) {
float el = asin(clamp(-r.y, -1., 1.)), az = atan(r.x, r.z);
float h = el + .45;
vec3 sky = mix(vec3(.58, .62, .7), vec3(.96, .98, 1.04), smoothstep(0., .8, h));
sky = mix(sky, vec3(.16, .17, .2), smoothstep(.62, .78, el) * smoothstep(1.02, .92, el));
sky = mix(sky, vec3(.42, .45, .52), smoothstep(1.3, 1.45, el));
vec3 grd = mix(vec3(.05, .045, .05), vec3(.012, .013, .016), smoothstep(0., .5, -h));
vec3 c = mix(grd, sky, smoothstep(-.012, .012, h)) + vec3(.7) * exp(-abs(h) * 45.);
c += vec3(1.8) * smoothstep(.95, 1.0, el) * smoothstep(1.3, 1.24, el);
c = mix(c, vec3(.02, .022, .03) + vec3(.06) * smoothstep(-.2, .6, -r.y), smoothstep(.05, -.35, r.z));
c += vec3(1., .5, .3) * 1.1 * exp(-pow((az + 1.75) * 1.8, 2.)) * exp(-pow((el - .12) * 2.6, 2.));
c += ACCENT * 1.1 * exp(-pow((az - 1.75) * 1.8, 2.)) * exp(-pow((el - .06) * 2.6, 2.));
float back = smoothstep(.1, -.5, r.z);
c += back * (vec3(1., .45, .26) * .35 * smoothstep(0., -.8, r.x) + ACCENT * .3 * smoothstep(0., .8, r.x));
return c;
}
void main() {
vec2 p = vec2(gl_FragCoord.x, RES.y - gl_FragCoord.y) / SCALE;
vec2 d = shape(p);
float s = clamp(-d.x / d.y, 0., 1.);
vec3 n = normal(p, s);
vec3 r = reflect(-VIEW, n);
vec3 col = env(r) * fresnel(n.z);
col += pow(max(dot(r, KEY), 0.), 32.);
col = mix(col, col * TINT, win);
// a lit traffic light shows in the metal around it: red on top, amber in the middle, green below
for (int i = 0; i < 3; i++) {
vec2 q = p - LAMP[i].xy;
float u = q.y / max(LAMP[i].z, 1.);
vec3 lamp = mix(mix(vec3(1., .3, .25), vec3(1., .78, .24), smoothstep(-.5, -.1, u)), vec3(.24, 1., .54), smoothstep(.1, .5, u));
col += lamp * LAMP[i].w * .9 * exp(-abs(max(abs(q.x), abs(q.y)) - LAMP[i].z) / 10.);
}
float a = clamp(.5 - d.x * SCALE, 0., 1.);
float shadow = .5 * smoothstep(26., -8., shape(p - vec2(0., 9.)).x);
float glow = win * .5 * exp(-max(d.x, 0.) / 16.);
o = vec4(clamp(col, 0., 1.) * a + vec3(.39, .95, .63) * glow * (1. - a), a + clamp(shadow + glow, 0., 1.) * (1. - a));
}`;
let gl, U = {}, scale = 1;
try {
gl = cv.getContext('webgl2', { premultipliedAlpha: true, antialias: false });
const compile = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw gl.getShaderInfoLog(s); return s; };
const prog = gl.createProgram();
gl.attachShader(prog, compile(gl.VERTEX_SHADER, '#version 300 es\nin vec2 a; void main() { gl_Position = vec4(a, 0., 1.); }'));
gl.attachShader(prog, compile(gl.FRAGMENT_SHADER, FS));
gl.linkProgram(prog); gl.useProgram(prog);
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
for (const n of ['BALL', 'KEY', 'SEG', 'RING', 'LAMP', 'SEGR', 'RES', 'MELT', 'SCALE', 'win']) U[n] = gl.getUniformLocation(prog, n);
scale = Math.min(devicePixelRatio || 1, 3);
cv.width = W * scale; cv.height = H * scale;
gl.viewport(0, 0, cv.width, cv.height);
gl.enable(gl.BLEND); gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
} catch (e) {
gl = null;
}
const still = reduce || !gl;
if (still) root.classList.add('still');
// the points of the tick, around the middle of the checkbox
function strokes() {
const c = centre(box);
return TICK.map(([x, y]) => ({ x: c.x + x * tick.size, y: c.y + y * tick.size }));
}
function draw() {
if (!gl) return;
const p = strokes(), k = tick.k, on = k > 0 ? 3.1 * tick.size : 0;
const mid = { x: lerp(p[0].x, p[1].x, clamp(k)), y: lerp(p[0].y, p[1].y, clamp(k)) };
const end = { x: lerp(p[1].x, p[2].x, clamp(k - 1)), y: lerp(p[1].y, p[2].y, clamp(k - 1)) };
const ring = i => rings[i] || { x: 0, y: 0, half: 0, w: 0, lit: 0 };
gl.uniform3fv(U.BALL, [drop.x, drop.y, drop.r, tail.x, tail.y, drop.r * .76, tip.x, tip.y, drop.r * .54]);
gl.uniform4fv(U.SEG, [p[0].x, p[0].y, mid.x, mid.y, p[1].x, p[1].y, end.x, end.y]);
gl.uniform2f(U.SEGR, on, k > 1 ? on : 0);
gl.uniform4fv(U.RING, [0, 1, 2].flatMap(i => [ring(i).x, ring(i).y, ring(i).half, ring(i).w]));
gl.uniform4fv(U.LAMP, [0, 1, 2].flatMap(i => [ring(i).x, ring(i).y, ring(i).half, ring(i).lit * heat]));
const a = clock * .62832 + (pointer ? (pointer.x - drop.x) * .004 : 0);
const key = [Math.cos(a) * .55, -.75, .7], len = Math.hypot(...key);
gl.uniform3f(U.KEY, key[0] / len, key[1] / len, key[2] / len);
gl.uniform2f(U.RES, cv.width, cv.height);
gl.uniform1f(U.MELT, MELT); gl.uniform1f(U.SCALE, scale); gl.uniform1f(U.win, win);
gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}
// the drop is pulled to its target on a spring, and a smaller blob trails behind it
function move(dt) {
const n = Math.max(1, Math.round(dt * 240)), h = dt / n;
for (let i = 0; i < n; i++) {
drop.vx += ((drop.tx - drop.x) * SPRING - drop.vx * DAMP) * h;
drop.vy += ((drop.ty - drop.y) * SPRING - drop.vy * DAMP) * h;
drop.x += drop.vx * h;
drop.y += drop.vy * h;
}
const follow = 1 - Math.exp(-dt * 12), slower = 1 - Math.exp(-dt * 8);
tail.x += (drop.x - tail.x) * follow;
tail.y += (drop.y - tail.y) * follow;
tip.x += (tail.x - tip.x) * slower;
tip.y += (tail.y - tip.y) * slower;
}
const to = (p, dx = 0, dy = 0) => { drop.tx = p.x + dx; drop.ty = p.y + dy; };
const rest = () => { const c = centre(isOpen() ? nest : home); return { x: c.x, y: c.y - (isOpen() ? 0 : 5) }; };
let before = 0;
function frame(now) {
const dt = Math.min((now - before) / 1000, .05);
before = now;
clock += dt;
// every light you pick makes all of them burn a little brighter
heat += (.6 + .2 * lights.filter(t => t.on).length - heat) * (1 - Math.exp(-dt * 5));
if (!busy && !done) {
// waiting: the drop breathes at its place and leans towards the pointer
const p = rest(), near = pointer ? clamp(1 - Math.hypot(pointer.x - p.x, pointer.y - p.y) / 150) : 0;
to(p, Math.sin(clock * 1.88496) * 1.4 + (pointer ? (pointer.x - p.x) * .06 * near : 0), Math.cos(clock * 1.25664) * 1.2 + (pointer ? (pointer.y - p.y) * .06 * near : 0));
}
move(dt);
draw();
requestAnimationFrame(frame);
}
function speak(text) {
say.textContent = text;
if (!reduce) say.animate([{ opacity: 0, translate: '0 4px' }, { opacity: 1, translate: '0 0' }], { duration: 200, easing: 'ease-out' });
}
function open() {
root.classList.add('open');
task.inert = false;
task.style.height = task.scrollHeight + 'px';
}
function shut() {
root.classList.remove('open');
task.inert = true;
task.style.height = '';
}
// the drop jumps into the checkbox and draws the tick with itself
async function drawTick(size) {
tick.size = size;
const p = strokes(), r0 = drop.r;
to(p[0]);
drop.vy -= 190; // a small hop on the way in
await wait(.3);
await tween(.42, k => {
tick.k = 2 * k;
const i = tick.k < 1 ? 0 : 1, u = tick.k - i;
drop.x = drop.tx = lerp(p[i].x, p[i + 1].x, u);
drop.y = drop.ty = lerp(p[i].y, p[i + 1].y, u);
drop.vx = drop.vy = 0;
drop.r = lerp(r0, 3.1 * size, k);
});
}
async function meltTick(r) {
const p = strokes(), r0 = drop.r;
await tween(.3, k => {
tick.k = 2 * (1 - k);
const i = tick.k < 1 ? 0 : 1, u = tick.k - i;
drop.x = drop.tx = lerp(p[i].x, p[i + 1].x, u);
drop.y = drop.ty = lerp(p[i].y, p[i + 1].y, u);
drop.r = lerp(r0, r, k);
});
tick.k = 0;
}
// the checkbox: the tick, then the picture test opens and waits for you
async function start() {
if (done || isOpen()) return;
box.setAttribute('aria-checked', 'mixed');
if (still) return open();
await drawTick(1);
open();
await wait(.2);
await meltTick(BIG);
}
async function choose(tile) {
if (!tile.light) return refuse(tile);
if (!tile.on) return pick(tile);
await letGo(tile);
}
function mark(tile, on) {
tile.on = on;
tile.classList.toggle('picked', on);
tile.setAttribute('aria-pressed', on);
tile.querySelectorAll('.lamp').forEach((lamp, i) => {
if (!on) return lamp.classList.remove('on');
setTimeout(() => tile.on && lamp.classList.add('on'), (still ? 0 : 280) + i * 90);
});
}
// a traffic light: the drop runs one lap along the edges, leaves a ring, and the lamps come on through it
async function pick(tile) {
mark(tile, true);
if (still) return;
const c = centre(tile), ring = tile.ring, r0 = drop.r, s = c.half - 16;
const lap = [[-s, -s], [s, -s], [s, s], [-s, s], [-s, -s]];
to(c, -s, -s);
await wait(.2);
Object.assign(ring, { x: c.x, y: c.y, half: c.half - 5 });
await tween(PICK, k => {
const u = Math.min(k * 4, 3.999), i = Math.floor(u);
to(c, lerp(lap[i][0], lap[i + 1][0], u - i), lerp(lap[i][1], lap[i + 1][1], u - i));
ring.w = 4.6 * k; ring.lit = k; drop.r = lerp(r0, r0 - 3, k);
}, k => k);
}
// picked by mistake: the ring flows back into the drop
async function letGo(tile) {
mark(tile, false);
if (still) return;
const c = centre(tile), ring = tile.ring, r0 = drop.r, w0 = ring.w, l0 = ring.lit;
to(c);
await wait(.18);
await tween(.26, k => { ring.w = w0 * (1 - k); ring.lit = l0 * (1 - k); drop.r = lerp(r0, r0 + 3, k); });
}
// not a traffic light: the drop rushes in and backs off, the square shakes no
async function refuse(tile) {
tile.animate([{ filter: 'none' }, { filter: 'brightness(.45) saturate(.4)' }, { filter: 'none' }], { duration: 700, easing: 'ease-out' });
if (reduce) return;
tile.animate([{ translate: '0 0' }, { translate: '-6px 0' }, { translate: '5px 0' }, { translate: '-3px 0' }, { translate: '0 0' }], { duration: 340, delay: gl ? 160 : 0, easing: 'ease-out' });
if (!gl) return;
const c = centre(tile), r0 = drop.r;
to(c);
await wait(.16);
drop.r = r0 * 1.22;
for (const dx of [8, -7, 4]) { to(c, dx, -3); await wait(.07); }
drop.r = r0;
}
// Verify with a square still missing: the drop stretches towards it and the square lights up
async function point(tile) {
const on = 'rgba(107, 235, 217, .95)', off = 'rgba(107, 235, 217, 0)';
tile.animate([{ outlineColor: off }, { outlineColor: on }, { outlineColor: off }, { outlineColor: on }, { outlineColor: off }], { duration: 1100, easing: 'ease-in-out' });
if (still) return;
const c = centre(tile);
to(c, -c.half * .35, -c.half * .35);
await wait(.55);
}
// every ring slides into the drop wherever it is, shrinking as it goes, and melts into it
function gather(sec) {
rings.forEach((ring, i) => {
if (!ring.w) return;
const a = { ...ring };
wait(i * .05).then(() => tween(sec, k => {
ring.x = lerp(a.x, drop.x, k); ring.y = lerp(a.y, drop.y, k);
ring.half = lerp(a.half, 9, k); ring.w = a.w * (1 - k * k); ring.lit = a.lit * (1 - k);
}));
});
}
async function verify() {
if (done || !isOpen()) return;
button.animate([{ scale: 1 }, { scale: .93 }, { scale: 1 }], { duration: 220, easing: 'ease-out' });
const miss = lights.find(t => !t.on);
if (miss) return point(miss);
if (!(await checkHuman())) return reset();
if (still) { shut(); return finish(); }
// the rings let go and everything runs back into one drop
const r0 = drop.r;
to(centre(grid));
gather(.34);
tween(.45, k => { drop.r = lerp(r0, BIG + 1.5, k); });
await wait(.38);
shut();
to(strokes()[0]);
await wait(.4);
await drawTick(1.3);
finish();
}
function finish() {
done = true;
root.classList.add('ok');
box.setAttribute('aria-checked', 'true');
speak('Verified.');
wait(.45).then(() => {
if (!done) return;
const more = document.createElement('span');
more.textContent = ' Probably human.';
say.append(more);
if (!reduce) more.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 220, easing: 'ease-out' });
});
if (still) return;
tween(.3, k => { win = k; });
}
// back to the empty checkbox: the rings and the tick melt into one drop and it goes home
async function reset() {
const was = done;
done = false;
root.classList.remove('ok');
box.setAttribute('aria-checked', 'false');
if (was) speak("I'm not a robot");
for (const tile of tiles) mark(tile, false);
if (still) return shut();
const r0 = drop.r, w0 = win;
tween(.3, k => { win = w0 * (1 - k); });
if (isOpen()) to(centre(grid));
gather(.34);
if (tick.k > 0) await meltTick(BIG);
else await tween(.34, k => { drop.r = lerp(r0, BIG, k); });
shut();
to(rest());
await wait(.35);
}
// every click waits for the drop to finish what it is doing, so quick clicks line up instead of fighting
let chain = Promise.resolve();
function run(job) {
chain = chain.then(async () => {
busy = true;
try { await job(); } finally { busy = false; }
}).catch(() => {});
}
box.addEventListener('click', () => run(done ? reset : start));
button.addEventListener('click', () => run(verify));
for (const tile of tiles) tile.addEventListener('click', () => run(() => isOpen() && !done && choose(tile)));
root.reset = () => run(reset);
addEventListener('pointermove', e => { const c = cv.getBoundingClientRect(); pointer = { x: e.clientX - c.left, y: e.clientY - c.top }; });
const p0 = rest();
Object.assign(drop, { x: p0.x, y: p0.y, tx: p0.x, ty: p0.y });
Object.assign(tail, p0);
Object.assign(tip, p0);
requestAnimationFrame(t => { before = t; requestAnimationFrame(frame); });
})();
</script>
Press the checkbox and watch the metal work. Move the pointer near the waiting drop, it leans towards it.
What you can change
Change a number, save, and reload the page to see the difference.
MELT20How eagerly two blobs of metal fuse, in px. 4 keeps them apart like beads, 30 makes one puddle.
SPRING260How hard the drop is pulled to where it is going.
DAMP22How fast the drop calms down. 8 makes it wobble like jelly.
PICK0.5Seconds the drop spends running a lap around one traffic light.
RESET1.0Seconds until the demo starts over. 0 keeps it verified.
Add it to your site
Sign up and checkout forms, comment forms, any place where a human check runs and the wait should feel like a show.
CSS
Paste into your stylesheet, or inside a <style> tag in <head>.
/* Liquid Metal Captcha by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */ .lmc { --accent: #6BEBD9; --ok: #63F2A0; position: relative; width: 284px; margin-top: max(40px, calc(50vh - 245px)); } .lmc canvas { position: absolute; left: -70px; top: -70px; z-index: 3; width: 424px; height: 620px; pointer-events: none; } .lmc .row, .lmc .task { position: relative; border-radius: 16px; background: linear-gradient(#151923, #10131B); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 0 0 1px rgba(255, 255, 255, .06), 0 24px 50px -22px rgba(0, 0, 0, .85); } .lmc .row { display: flex; align-items: center; gap: 13px; height: 70px; padding: 0 12px 0 18px; box-sizing: border-box; } .lmc .box { width: 34px; height: 34px; flex: none; padding: 0; border: 1.5px solid #3B4150; border-radius: 9px; background: #0A0C12; cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease; } .lmc button:focus-visible { outline: 3px solid rgba(107, 235, 217, .45); outline-offset: 2px; } .lmc.ok .box { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(99, 242, 160, .14); } .lmc .say { font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; } .lmc .home { position: absolute; right: 12px; top: 0; width: 62px; height: 100%; box-sizing: border-box; padding-top: 50px; text-align: center; color: #6B7282; font-size: 9px; letter-spacing: .05em; white-space: nowrap; transition: opacity .2s ease-out; } .lmc.ok .home { opacity: 0; } .lmc .task { height: 0; margin-top: 8px; overflow: hidden; opacity: 0; transition: height .42s cubic-bezier(.32, .72, 0, 1), opacity .25s ease-out; } .lmc.open .task { opacity: 1; } .lmc .head { padding: 11px 16px 10px; background: linear-gradient(#123235, #0E2628); } .lmc .head small { display: block; color: #A9D8D2; font-size: 12px; } .lmc .head b { color: #fff; font-size: 20px; letter-spacing: -.01em; } .lmc .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; } .lmc .tile { display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #0B0D13; outline: 3px solid transparent; outline-offset: -3px; cursor: pointer; transition: scale .16s ease-out; } .lmc .tile svg { display: block; width: 100%; height: 100%; } .lmc .tile.picked { scale: .93; } .lmc.still .tile.picked { outline-color: var(--accent); } .lmc .lamp { transition: fill .16s ease-out; } .lmc .lamp.r { fill: #4B1B17; } .lmc .lamp.y { fill: #4A3D14; } .lmc .lamp.g { fill: #14432A; } .lmc .lamp.r.on { fill: #FF5142; filter: drop-shadow(0 0 5px #FF5142); } .lmc .lamp.y.on { fill: #FFC83D; filter: drop-shadow(0 0 5px #FFC83D); } .lmc .lamp.g.on { fill: #3DFF8A; filter: drop-shadow(0 0 5px #3DFF8A); } .lmc .foot { display: flex; align-items: center; padding: 0 8px 8px 14px; } .lmc .nest { width: 40px; height: 34px; } .lmc .verify { height: 34px; margin-left: auto; padding: 0 18px; border: 0; border-radius: 9px; background: var(--accent); color: #062321; font: 700 13px system-ui, sans-serif; cursor: pointer; } .lmc.still.ok .box { background: var(--ok); }HTML
Put it where the effect should appear on your page.
<!-- EFFECT --> <div class="lmc" id="lmc"> <svg width="0" height="0" style="position:absolute" aria-hidden="true"><defs> <linearGradient id="lmc-dusk" x2="0" y2="1"><stop offset="0" stop-color="#1B2140"/><stop offset=".58" stop-color="#3D2B55"/><stop offset="1" stop-color="#B95B3A"/></linearGradient> <linearGradient id="lmc-night" x2="0" y2="1"><stop offset="0" stop-color="#0B1024"/><stop offset=".6" stop-color="#1B2248"/><stop offset="1" stop-color="#2E2D52"/></linearGradient> <linearGradient id="lmc-teal" x2="0" y2="1"><stop offset="0" stop-color="#0C1B26"/><stop offset=".6" stop-color="#13363D"/><stop offset="1" stop-color="#2B5A55"/></linearGradient> <filter id="lmc-soft" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="3.2"/></filter> </defs></svg> <canvas aria-hidden="true"></canvas> <div class="row"> <button class="box" type="button" role="checkbox" aria-checked="false" aria-label="I'm not a robot"></button> <span class="say" aria-live="polite">I'm not a robot</span> <span class="home">human check</span> </div> <div class="task" inert> <div class="head"><small>Select all squares with</small><b>traffic lights</b></div> <div class="grid"> <button class="tile" type="button" aria-pressed="false" aria-label="street lamp"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><circle cx="70" cy="27" r="17" fill="#FFC870" opacity="0.55" filter="url(#lmc-soft)"/><path d="M30 100V36c0-12 8-19 20-19h13" stroke="#07080B" stroke-width="5" fill="none" stroke-linecap="round"/><rect x="59" y="12" width="22" height="8" rx="3" fill="#07080B"/><ellipse cx="70" cy="21" rx="7.5" ry="2.4" fill="#FFE6B0"/></svg></button> <button class="tile light" type="button" aria-pressed="false" aria-label="traffic light"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><circle cx="18" cy="30" r="9" fill="#7C8CFF" opacity="0.35" filter="url(#lmc-soft)"/><circle cx="84" cy="62" r="11" fill="#FF9A5C" opacity="0.3" filter="url(#lmc-soft)"/><rect x="46.5" y="66" width="7" height="34" fill="#06070A"/><rect x="34" y="14" width="32" height="60" rx="8" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="50" cy="28" r="7.2"/><circle class="lamp y" cx="50" cy="44" r="7.2"/><circle class="lamp g" cx="50" cy="60" r="7.2"/></svg></button> <button class="tile" type="button" aria-pressed="false" aria-label="car"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><rect y="72" width="100" height="28" fill="#090A0E"/><circle cx="26" cy="63" r="9" fill="#FF4638" opacity="0.7" filter="url(#lmc-soft)"/><circle cx="74" cy="63" r="9" fill="#FF4638" opacity="0.7" filter="url(#lmc-soft)"/><path d="M16 76V61c0-4 3-7 7-8l8-13c2-3 5-5 9-5h20c4 0 7 2 9 5l8 13c4 1 7 4 7 8v15z" fill="#10131A"/><path d="M33 53l6-10c1-2 3-3 5-3h12c2 0 4 1 5 3l6 10z" fill="#27344A"/><rect x="21" y="60" width="13" height="6" rx="2" fill="#FF4638"/><rect x="66" y="60" width="13" height="6" rx="2" fill="#FF4638"/><rect x="22" y="76" width="12" height="9" rx="3" fill="#050608"/><rect x="66" y="76" width="12" height="9" rx="3" fill="#050608"/></svg></button> <button class="tile" type="button" aria-pressed="false" aria-label="bicycle"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><rect y="84" width="100" height="16" fill="#0A0B0F"/><g fill="none" stroke="#07080B" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="29" cy="70" r="14"/><circle cx="71" cy="70" r="14"/><path d="M29 70l13-25h20l9 25M42 45l12 25H29M62 45l-8 25M38 40h9M60 38h8"/></g></svg></button> <button class="tile" type="button" aria-pressed="false" aria-label="lit windows"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><rect x="14" y="8" width="72" height="92" fill="#0B0D14"/><rect x="22" y="16" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="16" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="16" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="16" width="9" height="10" rx="1" fill="#161A26"/><rect x="22" y="32" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="32" width="9" height="10" rx="1" fill="#161A26"/><rect x="52" y="32" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="32" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="22" y="48" width="9" height="10" rx="1" fill="#161A26"/><rect x="37" y="48" width="9" height="10" rx="1" fill="#161A26"/><rect x="52" y="48" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="67" y="48" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="22" y="64" width="9" height="10" rx="1" fill="#161A26"/><rect x="37" y="64" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="64" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="67" y="64" width="9" height="10" rx="1" fill="#161A26"/><rect x="22" y="80" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="37" y="80" width="9" height="10" rx="1" fill="#FFD27A"/><rect x="52" y="80" width="9" height="10" rx="1" fill="#161A26"/><rect x="67" y="80" width="9" height="10" rx="1" fill="#FFD27A"/></svg></button> <button class="tile light" type="button" aria-pressed="false" aria-label="edge of a traffic light"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><circle cx="66" cy="72" r="12" fill="#6BEBD9" opacity="0.22" filter="url(#lmc-soft)"/><path d="M86 100V24H22" stroke="#06070A" stroke-width="5" fill="none" stroke-linecap="round" stroke-linejoin="round"/><rect x="-4" y="4" width="26" height="50" rx="6" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="9" cy="16" r="5.2"/><circle class="lamp y" cx="9" cy="29" r="5.2"/><circle class="lamp g" cx="9" cy="42" r="5.2"/><path d="M0 92h100" stroke="#1A2A2E" stroke-width="2"/></svg></button> <button class="tile light" type="button" aria-pressed="false" aria-label="traffic light over the street"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-dusk)"/><path d="M0 100V70h12V58h10v12h8V50h12v20h10v30z" fill="#0A0B10"/><rect x="69" y="70" width="6" height="30" fill="#06070A"/><rect x="58" y="16" width="28" height="56" rx="7" fill="#0C0E13" stroke="#1C2029"/><circle class="lamp r" cx="72" cy="30" r="6.6"/><circle class="lamp y" cx="72" cy="44" r="6.6"/><circle class="lamp g" cx="72" cy="58" r="6.6"/></svg></button> <button class="tile" type="button" aria-pressed="false" aria-label="crosswalk"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-night)"/><path d="M0 100L30 52h40l30 48z" fill="#0A0B10"/><path d="M30.0 56.0h40.0l2.6 4.6H27.4z" fill="#D9DDE8" opacity=".82"/><path d="M22.6 65.4h54.8l2.6 4.6H20.0z" fill="#D9DDE8" opacity=".82"/><path d="M15.2 74.8h69.6l2.6 4.6H12.6z" fill="#D9DDE8" opacity=".82"/><path d="M7.8 84.2h84.4l2.6 4.6H5.2z" fill="#D9DDE8" opacity=".82"/><path d="M0.4 93.6h99.2l2.6 4.6H-2.2z" fill="#D9DDE8" opacity=".82"/></svg></button> <button class="tile" type="button" aria-pressed="false" aria-label="fire hydrant"><svg viewBox="0 0 100 100" aria-hidden="true"><rect width="100" height="100" fill="url(#lmc-teal)"/><rect y="82" width="100" height="18" fill="#0A0B0F"/><g fill="#D8452F"><rect x="40" y="46" width="20" height="38" rx="4"/><path d="M38 47h24l-3-9H41z"/><circle cx="50" cy="36" r="5"/><rect x="31" y="54" width="10" height="9" rx="2.5"/><rect x="59" y="54" width="10" height="9" rx="2.5"/><rect x="36" y="82" width="28" height="5" rx="2"/></g><rect x="44" y="52" width="4" height="26" rx="2" fill="#F07A5E" opacity=".6"/></svg></button> </div> <div class="foot"><span class="nest"></span><button class="verify" type="button">Verify</button></div> </div> </div> <!-- /EFFECT -->JavaScript
Paste right before the closing </body> tag, inside <script></script>.
/* Liquid Metal Captcha by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */ (() => { const MELT = 20; const SPRING = 260; const DAMP = 22; const PICK = 0.5; async function checkHuman() { // run your real check here and return true when the visitor passed return true; } const root = document.getElementById('lmc'), cv = root.querySelector('canvas'); const box = root.querySelector('.box'), say = root.querySelector('.say'), home = root.querySelector('.home'); const task = root.querySelector('.task'), grid = root.querySelector('.grid'), nest = root.querySelector('.nest'), button = root.querySelector('.verify'); const tiles = [...root.querySelectorAll('.tile')]; const lights = tiles.filter(t => t.classList.contains('light')); const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; for (const tile of tiles) { tile.light = lights.includes(tile); tile.on = false; } const TICK = [[-9, 1], [-3, 8], [10.5, -8]]; const W = 424, H = 620, BIG = 19; const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x)); const lerp = (a, b, k) => a + (b - a) * k; const out = k => 1 - (1 - k) ** 3; const wait = s => new Promise(done => setTimeout(done, s * 1000)); function tween(sec, fn, ease = out) { return new Promise(done => { const t0 = performance.now(); requestAnimationFrame(function tick(now) { const k = clamp((now - t0) / (sec * 1000)); fn(ease(k)); if (k < 1) requestAnimationFrame(tick); else done(); }); }); } // the middle of an element, measured from the corner of the canvas function centre(el) { const r = el.getBoundingClientRect(), c = cv.getBoundingClientRect(); return { x: r.left - c.left + r.width / 2, y: r.top - c.top + r.height / 2, half: r.width / 2 }; } const isOpen = () => root.classList.contains('open'); const drop = { x: 0, y: 0, vx: 0, vy: 0, tx: 0, ty: 0, r: BIG }; const tail = { x: 0, y: 0 }, tip = { x: 0, y: 0 }; const tick = { k: 0, size: 1 }; const rings = lights.map(() => ({ x: 0, y: 0, half: 0, w: 0, lit: 0 })); lights.forEach((tile, i) => { tile.ring = rings[i]; }); let win = 0, heat = .8, busy = false, done = false, pointer = null, clock = 0; const FS = `#version 300 es precision highp float; uniform vec3 BALL[3], KEY; uniform vec4 SEG[2], RING[3], LAMP[3]; uniform vec2 SEGR, RES; uniform float MELT, SCALE, win; out vec4 o; const vec3 VIEW = vec3(0., 0., 1.), TINT = vec3(.5, 1., .72), ACCENT = vec3(.42, .92, .85); float box(vec2 p, float b, float r) { vec2 q = abs(p) - b + r; return min(max(q.x, q.y), 0.) + length(max(q, 0.)) - r; } float seg(vec2 p, vec2 a, vec2 b) { vec2 pa = p - a, ba = b - a; return length(pa - ba * clamp(dot(pa, ba) / max(dot(ba, ba), 1e-4), 0., 1.)); } vec2 smin(vec2 a, vec2 b, float k) { float h = clamp(.5 + .5 * (b.x - a.x) / k, 0., 1.); return vec2(mix(b.x, a.x, h) - k * h * (1. - h), mix(b.y, a.y, h)); } vec2 shape(vec2 p) { vec2 d = vec2(1e4, 1.); for (int i = 0; i < 3; i++) if (BALL[i].z > 0.) d = smin(d, vec2(length(p - BALL[i].xy) - BALL[i].z, BALL[i].z), MELT); for (int i = 0; i < 2; i++) if (SEGR[i] > 0.) d = smin(d, vec2(seg(p, SEG[i].xy, SEG[i].zw) - SEGR[i], SEGR[i]), MELT * .18); for (int i = 0; i < 3; i++) if (RING[i].w > 0.) d = smin(d, vec2(abs(box(p - RING[i].xy, RING[i].z, 9.)) - RING[i].w, RING[i].w), MELT * .5); return d; } vec3 normal(vec2 p, float s) { vec2 e = vec2(.4, 0.); vec2 g = vec2(shape(p + e.xy).x - shape(p - e.xy).x, shape(p + e.yx).x - shape(p - e.yx).x); float slope = min((1. - s) / sqrt(max(1. - (1. - s) * (1. - s), 1e-4)), 14.); return normalize(vec3(normalize(g + 1e-6) * slope, 1.)); } float fresnel(float c) { return mix(.8, 1., pow(1. - c, 5.)); } vec3 env(vec3 r) { float el = asin(clamp(-r.y, -1., 1.)), az = atan(r.x, r.z); float h = el + .45; vec3 sky = mix(vec3(.58, .62, .7), vec3(.96, .98, 1.04), smoothstep(0., .8, h)); sky = mix(sky, vec3(.16, .17, .2), smoothstep(.62, .78, el) * smoothstep(1.02, .92, el)); sky = mix(sky, vec3(.42, .45, .52), smoothstep(1.3, 1.45, el)); vec3 grd = mix(vec3(.05, .045, .05), vec3(.012, .013, .016), smoothstep(0., .5, -h)); vec3 c = mix(grd, sky, smoothstep(-.012, .012, h)) + vec3(.7) * exp(-abs(h) * 45.); c += vec3(1.8) * smoothstep(.95, 1.0, el) * smoothstep(1.3, 1.24, el); c = mix(c, vec3(.02, .022, .03) + vec3(.06) * smoothstep(-.2, .6, -r.y), smoothstep(.05, -.35, r.z)); c += vec3(1., .5, .3) * 1.1 * exp(-pow((az + 1.75) * 1.8, 2.)) * exp(-pow((el - .12) * 2.6, 2.)); c += ACCENT * 1.1 * exp(-pow((az - 1.75) * 1.8, 2.)) * exp(-pow((el - .06) * 2.6, 2.)); float back = smoothstep(.1, -.5, r.z); c += back * (vec3(1., .45, .26) * .35 * smoothstep(0., -.8, r.x) + ACCENT * .3 * smoothstep(0., .8, r.x)); return c; } void main() { vec2 p = vec2(gl_FragCoord.x, RES.y - gl_FragCoord.y) / SCALE; vec2 d = shape(p); float s = clamp(-d.x / d.y, 0., 1.); vec3 n = normal(p, s); vec3 r = reflect(-VIEW, n); vec3 col = env(r) * fresnel(n.z); col += pow(max(dot(r, KEY), 0.), 32.); col = mix(col, col * TINT, win); // a lit traffic light shows in the metal around it: red on top, amber in the middle, green below for (int i = 0; i < 3; i++) { vec2 q = p - LAMP[i].xy; float u = q.y / max(LAMP[i].z, 1.); vec3 lamp = mix(mix(vec3(1., .3, .25), vec3(1., .78, .24), smoothstep(-.5, -.1, u)), vec3(.24, 1., .54), smoothstep(.1, .5, u)); col += lamp * LAMP[i].w * .9 * exp(-abs(max(abs(q.x), abs(q.y)) - LAMP[i].z) / 10.); } float a = clamp(.5 - d.x * SCALE, 0., 1.); float shadow = .5 * smoothstep(26., -8., shape(p - vec2(0., 9.)).x); float glow = win * .5 * exp(-max(d.x, 0.) / 16.); o = vec4(clamp(col, 0., 1.) * a + vec3(.39, .95, .63) * glow * (1. - a), a + clamp(shadow + glow, 0., 1.) * (1. - a)); }`; let gl, U = {}, scale = 1; try { gl = cv.getContext('webgl2', { premultipliedAlpha: true, antialias: false }); const compile = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw gl.getShaderInfoLog(s); return s; }; const prog = gl.createProgram(); gl.attachShader(prog, compile(gl.VERTEX_SHADER, '#version 300 es\nin vec2 a; void main() { gl_Position = vec4(a, 0., 1.); }')); gl.attachShader(prog, compile(gl.FRAGMENT_SHADER, FS)); gl.linkProgram(prog); gl.useProgram(prog); gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW); gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); for (const n of ['BALL', 'KEY', 'SEG', 'RING', 'LAMP', 'SEGR', 'RES', 'MELT', 'SCALE', 'win']) U[n] = gl.getUniformLocation(prog, n); scale = Math.min(devicePixelRatio || 1, 3); cv.width = W * scale; cv.height = H * scale; gl.viewport(0, 0, cv.width, cv.height); gl.enable(gl.BLEND); gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); } catch (e) { gl = null; } const still = reduce || !gl; if (still) root.classList.add('still'); // the points of the tick, around the middle of the checkbox function strokes() { const c = centre(box); return TICK.map(([x, y]) => ({ x: c.x + x * tick.size, y: c.y + y * tick.size })); } function draw() { if (!gl) return; const p = strokes(), k = tick.k, on = k > 0 ? 3.1 * tick.size : 0; const mid = { x: lerp(p[0].x, p[1].x, clamp(k)), y: lerp(p[0].y, p[1].y, clamp(k)) }; const end = { x: lerp(p[1].x, p[2].x, clamp(k - 1)), y: lerp(p[1].y, p[2].y, clamp(k - 1)) }; const ring = i => rings[i] || { x: 0, y: 0, half: 0, w: 0, lit: 0 }; gl.uniform3fv(U.BALL, [drop.x, drop.y, drop.r, tail.x, tail.y, drop.r * .76, tip.x, tip.y, drop.r * .54]); gl.uniform4fv(U.SEG, [p[0].x, p[0].y, mid.x, mid.y, p[1].x, p[1].y, end.x, end.y]); gl.uniform2f(U.SEGR, on, k > 1 ? on : 0); gl.uniform4fv(U.RING, [0, 1, 2].flatMap(i => [ring(i).x, ring(i).y, ring(i).half, ring(i).w])); gl.uniform4fv(U.LAMP, [0, 1, 2].flatMap(i => [ring(i).x, ring(i).y, ring(i).half, ring(i).lit * heat])); const a = clock * .62832 + (pointer ? (pointer.x - drop.x) * .004 : 0); const key = [Math.cos(a) * .55, -.75, .7], len = Math.hypot(...key); gl.uniform3f(U.KEY, key[0] / len, key[1] / len, key[2] / len); gl.uniform2f(U.RES, cv.width, cv.height); gl.uniform1f(U.MELT, MELT); gl.uniform1f(U.SCALE, scale); gl.uniform1f(U.win, win); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); } // the drop is pulled to its target on a spring, and a smaller blob trails behind it function move(dt) { const n = Math.max(1, Math.round(dt * 240)), h = dt / n; for (let i = 0; i < n; i++) { drop.vx += ((drop.tx - drop.x) * SPRING - drop.vx * DAMP) * h; drop.vy += ((drop.ty - drop.y) * SPRING - drop.vy * DAMP) * h; drop.x += drop.vx * h; drop.y += drop.vy * h; } const follow = 1 - Math.exp(-dt * 12), slower = 1 - Math.exp(-dt * 8); tail.x += (drop.x - tail.x) * follow; tail.y += (drop.y - tail.y) * follow; tip.x += (tail.x - tip.x) * slower; tip.y += (tail.y - tip.y) * slower; } const to = (p, dx = 0, dy = 0) => { drop.tx = p.x + dx; drop.ty = p.y + dy; }; const rest = () => { const c = centre(isOpen() ? nest : home); return { x: c.x, y: c.y - (isOpen() ? 0 : 5) }; }; let before = 0; function frame(now) { const dt = Math.min((now - before) / 1000, .05); before = now; clock += dt; // every light you pick makes all of them burn a little brighter heat += (.6 + .2 * lights.filter(t => t.on).length - heat) * (1 - Math.exp(-dt * 5)); if (!busy && !done) { // waiting: the drop breathes at its place and leans towards the pointer const p = rest(), near = pointer ? clamp(1 - Math.hypot(pointer.x - p.x, pointer.y - p.y) / 150) : 0; to(p, Math.sin(clock * 1.88496) * 1.4 + (pointer ? (pointer.x - p.x) * .06 * near : 0), Math.cos(clock * 1.25664) * 1.2 + (pointer ? (pointer.y - p.y) * .06 * near : 0)); } move(dt); draw(); requestAnimationFrame(frame); } function speak(text) { say.textContent = text; if (!reduce) say.animate([{ opacity: 0, translate: '0 4px' }, { opacity: 1, translate: '0 0' }], { duration: 200, easing: 'ease-out' }); } function open() { root.classList.add('open'); task.inert = false; task.style.height = task.scrollHeight + 'px'; } function shut() { root.classList.remove('open'); task.inert = true; task.style.height = ''; } // the drop jumps into the checkbox and draws the tick with itself async function drawTick(size) { tick.size = size; const p = strokes(), r0 = drop.r; to(p[0]); drop.vy -= 190; // a small hop on the way in await wait(.3); await tween(.42, k => { tick.k = 2 * k; const i = tick.k < 1 ? 0 : 1, u = tick.k - i; drop.x = drop.tx = lerp(p[i].x, p[i + 1].x, u); drop.y = drop.ty = lerp(p[i].y, p[i + 1].y, u); drop.vx = drop.vy = 0; drop.r = lerp(r0, 3.1 * size, k); }); } async function meltTick(r) { const p = strokes(), r0 = drop.r; await tween(.3, k => { tick.k = 2 * (1 - k); const i = tick.k < 1 ? 0 : 1, u = tick.k - i; drop.x = drop.tx = lerp(p[i].x, p[i + 1].x, u); drop.y = drop.ty = lerp(p[i].y, p[i + 1].y, u); drop.r = lerp(r0, r, k); }); tick.k = 0; } // the checkbox: the tick, then the picture test opens and waits for you async function start() { if (done || isOpen()) return; box.setAttribute('aria-checked', 'mixed'); if (still) return open(); await drawTick(1); open(); await wait(.2); await meltTick(BIG); } async function choose(tile) { if (!tile.light) return refuse(tile); if (!tile.on) return pick(tile); await letGo(tile); } function mark(tile, on) { tile.on = on; tile.classList.toggle('picked', on); tile.setAttribute('aria-pressed', on); tile.querySelectorAll('.lamp').forEach((lamp, i) => { if (!on) return lamp.classList.remove('on'); setTimeout(() => tile.on && lamp.classList.add('on'), (still ? 0 : 280) + i * 90); }); } // a traffic light: the drop runs one lap along the edges, leaves a ring, and the lamps come on through it async function pick(tile) { mark(tile, true); if (still) return; const c = centre(tile), ring = tile.ring, r0 = drop.r, s = c.half - 16; const lap = [[-s, -s], [s, -s], [s, s], [-s, s], [-s, -s]]; to(c, -s, -s); await wait(.2); Object.assign(ring, { x: c.x, y: c.y, half: c.half - 5 }); await tween(PICK, k => { const u = Math.min(k * 4, 3.999), i = Math.floor(u); to(c, lerp(lap[i][0], lap[i + 1][0], u - i), lerp(lap[i][1], lap[i + 1][1], u - i)); ring.w = 4.6 * k; ring.lit = k; drop.r = lerp(r0, r0 - 3, k); }, k => k); } // picked by mistake: the ring flows back into the drop async function letGo(tile) { mark(tile, false); if (still) return; const c = centre(tile), ring = tile.ring, r0 = drop.r, w0 = ring.w, l0 = ring.lit; to(c); await wait(.18); await tween(.26, k => { ring.w = w0 * (1 - k); ring.lit = l0 * (1 - k); drop.r = lerp(r0, r0 + 3, k); }); } // not a traffic light: the drop rushes in and backs off, the square shakes no async function refuse(tile) { tile.animate([{ filter: 'none' }, { filter: 'brightness(.45) saturate(.4)' }, { filter: 'none' }], { duration: 700, easing: 'ease-out' }); if (reduce) return; tile.animate([{ translate: '0 0' }, { translate: '-6px 0' }, { translate: '5px 0' }, { translate: '-3px 0' }, { translate: '0 0' }], { duration: 340, delay: gl ? 160 : 0, easing: 'ease-out' }); if (!gl) return; const c = centre(tile), r0 = drop.r; to(c); await wait(.16); drop.r = r0 * 1.22; for (const dx of [8, -7, 4]) { to(c, dx, -3); await wait(.07); } drop.r = r0; } // Verify with a square still missing: the drop stretches towards it and the square lights up async function point(tile) { const on = 'rgba(107, 235, 217, .95)', off = 'rgba(107, 235, 217, 0)'; tile.animate([{ outlineColor: off }, { outlineColor: on }, { outlineColor: off }, { outlineColor: on }, { outlineColor: off }], { duration: 1100, easing: 'ease-in-out' }); if (still) return; const c = centre(tile); to(c, -c.half * .35, -c.half * .35); await wait(.55); } // every ring slides into the drop wherever it is, shrinking as it goes, and melts into it function gather(sec) { rings.forEach((ring, i) => { if (!ring.w) return; const a = { ...ring }; wait(i * .05).then(() => tween(sec, k => { ring.x = lerp(a.x, drop.x, k); ring.y = lerp(a.y, drop.y, k); ring.half = lerp(a.half, 9, k); ring.w = a.w * (1 - k * k); ring.lit = a.lit * (1 - k); })); }); } async function verify() { if (done || !isOpen()) return; button.animate([{ scale: 1 }, { scale: .93 }, { scale: 1 }], { duration: 220, easing: 'ease-out' }); const miss = lights.find(t => !t.on); if (miss) return point(miss); if (!(await checkHuman())) return reset(); if (still) { shut(); return finish(); } // the rings let go and everything runs back into one drop const r0 = drop.r; to(centre(grid)); gather(.34); tween(.45, k => { drop.r = lerp(r0, BIG + 1.5, k); }); await wait(.38); shut(); to(strokes()[0]); await wait(.4); await drawTick(1.3); finish(); } function finish() { done = true; root.classList.add('ok'); box.setAttribute('aria-checked', 'true'); speak('Verified.'); wait(.45).then(() => { if (!done) return; const more = document.createElement('span'); more.textContent = ' Probably human.'; say.append(more); if (!reduce) more.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 220, easing: 'ease-out' }); }); if (still) return; tween(.3, k => { win = k; }); } // back to the empty checkbox: the rings and the tick melt into one drop and it goes home async function reset() { const was = done; done = false; root.classList.remove('ok'); box.setAttribute('aria-checked', 'false'); if (was) speak("I'm not a robot"); for (const tile of tiles) mark(tile, false); if (still) return shut(); const r0 = drop.r, w0 = win; tween(.3, k => { win = w0 * (1 - k); }); if (isOpen()) to(centre(grid)); gather(.34); if (tick.k > 0) await meltTick(BIG); else await tween(.34, k => { drop.r = lerp(r0, BIG, k); }); shut(); to(rest()); await wait(.35); } // every click waits for the drop to finish what it is doing, so quick clicks line up instead of fighting let chain = Promise.resolve(); function run(job) { chain = chain.then(async () => { busy = true; try { await job(); } finally { busy = false; } }).catch(() => {}); } box.addEventListener('click', () => run(done ? reset : start)); button.addEventListener('click', () => run(verify)); for (const tile of tiles) tile.addEventListener('click', () => run(() => isOpen() && !done && choose(tile))); root.reset = () => run(reset); addEventListener('pointermove', e => { const c = cv.getBoundingClientRect(); pointer = { x: e.clientX - c.left, y: e.clientY - c.top }; }); const p0 = rest(); Object.assign(drop, { x: p0.x, y: p0.y, tx: p0.x, ty: p0.y }); Object.assign(tail, p0); Object.assign(tip, p0); requestAnimationFrame(t => { before = t; requestAnimationFrame(frame); }); })();
Connect it to your backend
This is the animation, not the protection. Run your real check in checkHuman() and return true when the visitor passed.
Good to know
- The metal is one canvas with a WebGL shader: balls, two strokes of the tick and three square rings blended with a smooth minimum.
- The drop moves on a spring with two smaller blobs trailing behind, so it stretches like mercury.
- Wrong squares make the drop flinch and go dim, traffic lights get a metal ring and their lamps reflect in it.
- The squares are plain inline SVG, swap in your own pictures.
- No libraries.
- With reduced motion the tick appears at once without the trip.
Tilda, Webflow, WordPress
Press Copy all code at the top and paste it into one HTML block.
Add block, Other, T123 HTML code. Paste and save. Check the published page, the editor preview does not run scripts.
Add panel, Embed. Paste, then Save & Close. Custom code runs on the published site.
Add block, Custom HTML. Paste and press Update.



