VibeFX
Live preview · fully interactive

The prompt

Build a dot grid that repels from the pointer.

## Look
2.2px dots, fill #c4b5fd, on a 28px grid over #08080d.

## Behavior
If a dot is within 120px of the pointer, push it away along the vector by up to 22px, scaled by how close it is. Dots farther than 120px stay put.

## Design tokens
- Dots #c4b5fd; page #08080d.

## Motion
- Push radius 120px, max push 22px, updated every frame. No spring library.

## Constraints
- Single self-contained HTML file. No libraries. Canvas 2D.
- Honor prefers-reduced-motion: reduce by skipping the loop and leaving a readable static frame
- Readable at 390px width with no horizontal page scroll

The code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { min-height: 100%; }
  body {
    background: #08080d; color: #f2f2f7; font-family: Inter, system-ui, sans-serif;
    min-height: 100vh; overflow: hidden;
  }
  .hint { position: absolute; left: 16px; top: 16px; z-index: 5; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8a8a99; }
  canvas { position: fixed; inset: 0; width: 100%; height: 100%; }
  @media (max-width: 420px) {
    .hint { font-size: 10px; letter-spacing: 0.08em; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  }
</style>
</head>
<body>
<p class="hint">Dots move aside</p><canvas id="c"></canvas>

<script>

  var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  var pointer = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
  var userMoved = false;
  window.addEventListener("pointermove", function (e) {
    userMoved = true;
    pointer.x = e.clientX;
    pointer.y = e.clientY;
  });
  function idlePointer(now) {
    if (userMoved || reduce) return;
    pointer.x = window.innerWidth * (0.5 + Math.cos(now / 700) * 0.28);
    pointer.y = window.innerHeight * (0.5 + Math.sin(now / 900) * 0.2);
  }

  var canvas = document.getElementById("c");
  var ctx = canvas.getContext("2d");
  function resize() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }
  resize();
  window.addEventListener("resize", resize);
  function frame(now) {
    idlePointer(now);
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = "#c4b5fd";
    var gap = 28;
    for (var y = gap; y < canvas.height; y += gap) {
      for (var x = gap; x < canvas.width; x += gap) {
        var dx = x - pointer.x, dy = y - pointer.y;
        var dist = Math.hypot(dx, dy) || 1;
        var push = dist < 120 ? (1 - dist / 120) * 22 : 0;
        ctx.beginPath();
        ctx.arc(x + (dx / dist) * push, y + (dy / dist) * push, 2.2, 0, Math.PI * 2);
        ctx.fill();
      }
    }
    if (!reduce) requestAnimationFrame(frame);
  }
  requestAnimationFrame(frame);
</script>
</body>
</html>

About this effect

Dots sit on a 28px grid. Inside a 120px radius they translate away from the pointer, farther when closer. Outside the radius they rest. The field is the interaction.

Similar effects