Skip to main content

Jump to

↑ ↓ to move · Enter to openCtrl / ⌘ K

Every page and action

Roktim Ashraful · work

Particle Portrait

Turn a photo into an interactive portrait made of thousands of particles. Background removal, tuning and export all happen in your browser.

  • Free, no sign-up
  • Your photo stays on your device
  • React or plain HTML

Move your cursor over the face · click for a shockwaveDrag across the face · tap for a shockwave

How it works

One browser tab, from photo to a component you can ship.

  1. Upload a photo

    A head-and-shoulders photo works best. An AI model running on your device removes the background and frames the face.

  2. Tune it

    Set the density, particle size, colours and how the particles react to the cursor. The preview updates as you drag.

  3. Export

    Copy a prompt for your AI coding assistant, or download a React component or a plain HTML, CSS and JS kit with your photo included.

Take it anywhere

Every export carries your settings and the same engine this page runs.

  • React componentA typed component, the engine, an example with your settings and your processed photo.
  • HTML, CSS and JSA page that opens straight from the disk: no build step, no dependencies.
  • AI promptYour settings and the technique, written for an AI coding assistant to rebuild in any stack.
import ParticlePortrait from "./particle-portrait/ParticlePortrait";

export default function PortraitHero() {
  return (
    <ParticlePortrait
      style={{ width: "min(100%, 420px)", aspectRatio: "640 / 716" }}
      src="/portrait.webp"
      label="Portrait drawn in particles"
      gap={3}
      particleSize={2.3}
      radius={90}
      spring={0.055}
      damping={0.84}
      baseColor="#e5e5e5"
      accentColor="#ffffff"
      backgroundColor="#000000"
      fade={0.2}
      intro={true}
    />
  );
}

Under the hood

A small engine written from scratch: no WebGL, no libraries, about 400 lines.

Background removal on your device
MediaPipe's selfie segmenter runs in WebAssembly in your browser. The model downloads once (about 26 MB); your photo is never uploaded.
Halftone sampling
Brightness is stretched to the subject's own range and sharpened with local contrast, so eyes, brows and lips separate from the skin.
Detail where identity lives
A Sobel filter adds finer particles on feature edges and lights the silhouette like rim light, so hair and jaw read on a dark page.
One buffer, one upload per frame
Particles are splatted into a pixel buffer and drawn with a single putImageData. The loop sleeps when nothing moves and lowers its resolution on slow devices.
Spring physics
Each particle remembers its home. The cursor pushes with a smooth falloff, a click sends a ring-shaped wave, and a damped spring brings everything back.
Accessible by default
With reduced motion the portrait stays still, the canvas carries a text label, and every control works from the keyboard.

See yourself in particles

Upload a photo, tune it until it feels right, and take the result to your own site.

Open the studio

Designed and built by Roktim Ashraful