webdevpuneet.com

Paper.js Vector Blob — Free Mouse-Reactive Organic Shape Snippet

Paper.js Vector Blob · Animations · Plain HTML, CSS & JS · Live preview

CategoryAnimations

Copy & paste

Source Code

Requires
<div class="pb-wrap">
  <canvas id="pbCanvas" class="pb-canvas" resize></canvas>
  <p class="pb-hint">Move your cursor near the blob — it stretches toward it.</p>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Vector point math
Paper.js Point operations, not raw canvas pixels.
Per-point wobble
Independent phase/speed avoid synchronized pulsing.
Continuous smoothing
path.smooth() turns points into a fluid curve.
Cursor-reactive distortion
Nearby points pull toward the mouse.
Eased mouse tracking
Lerped position avoids snapping on fast moves.
Radial gradient fill
Three-stop gradient anchored to canvas center.
Frame-driven rebuild
onFrame recalculates segments every tick.
Responsive canvas
resize attribute keeps it sized to its container.

About this UI Snippet

Paper.js Vector Blob — A Wobbling, Cursor-Reactive Organic Shape

Screenshot of the Paper.js Vector Blob snippet rendered live

Paper.js is a vector graphics scripting engine for the browser — it gives you a scene graph of Path, Point, and Segment objects with real vector math (.add, .subtract, .normalize, .length) instead of raw canvas pixel pushing. This snippet uses that to build an organic blob: ten points arranged on a circle, each with an independent sine-wave wobble, smoothed into a continuous curve and redrawn every frame via paper.view.onFrame — with the whole shape leaning toward the cursor as it moves nearby.

Points, not a fixed path

Rather than drawing one static Path and animating its transform, this snippet rebuilds the path's segments from scratch every frame. Ten anchor points sit on a circle at even angular intervals, each carrying its own random phase and speed so Math.sin(time * speed + phase) produces a wobble that's never in sync across points — that desynchronization is what makes the blob read as organic rather than a pulsing circle.

Continuous smoothing turns points into curves

After the ten distorted points are added, path.smooth({ type: 'continuous' }) converts the straight-line polygon between them into a smooth, C1-continuous curve — Paper.js computes handle positions automatically so there's no visible corner even where a point moves sharply between frames. This single call is what turns "ten dots on a circle" into a fluid blob shape.

Mouse reactivity via vector subtraction

Each frame, every point's position is compared to an eased mouse position (itself lerped toward the real cursor with .add(...).multiply(0.08) for smoothing) using mouse.subtract(pointPos) to get a direction-and-distance vector. Points within 220px of the cursor get pushed outward along that vector, scaled by proximity — Math.max(0, 1 - dist / 220) * 40 — so the blob stretches toward wherever the cursor lingers and relaxes back when it moves away.

Where this fits

For a mouse-reactive cursor trail rather than a shape distortion, see quickto cursor; for a CSS-only organic shape without vector math, see liquid blob. Paper.js is the right tool specifically when you need real per-point vector operations rather than a CSS filter or SVG morph.

Customizing it

Change POINTS for a smoother (more points) or more angular (fewer points) blob, adjust BASE_RADIUS and wobble amplitude, or swap the gradient fill for a flat color. Increase the 220/40 proximity constants for a more dramatic, longer-reaching cursor pull.

Step by step

How to Use

  1. 1
    Add the paper.js CDNInclude paper-full.min.js from the CDN panel.
  2. 2
    Paste HTML, CSS, and JSA canvas renders with a gradient-filled blob.
  3. 3
    Watch it idleThe blob wobbles continuously via per-point sine waves.
  4. 4
    Move your cursor near itNearby points stretch outward toward the cursor.
  5. 5
    Move awayThe blob relaxes back to its base wobble.
  6. 6
    Tune the shapeAdjust POINTS, BASE_RADIUS, and pull constants.

Real-world uses

Common Use Cases

Hero background shapes
Place an organic focal point behind headline text, with each point wobbling at its own phase and speed so the shape never pulses in sync.
Idle and loading states
Show a living shape in place of a static spinner, where path.smooth() turns the points into a fluid continuous curve.
Mouse-reactive brand marks
Give a landing page a distinctive mark whose nearby points pull toward the pointer, built with Paper.js Point maths.
Cursor interaction pairings
Pair with a quickTo cursor so a smooth follower and a reactive blob share the pointer.
CSS blob alternatives
Compare with the liquid blob to decide between a vector-scripted shape and a pure CSS one.

Got questions?

Frequently Asked Questions

The blob's shape itself changes — points wobble at independent rates and distort toward the cursor — not just its position or scale, so a single CSS-style transform can't express it. Rebuilding segments from ten freshly calculated points each frame, then re-smoothing, is how Paper.js redraws a genuinely different outline every tick rather than moving a fixed shape around.

It takes the current straight-line segments (the raw points just added) and computes Bezier handle positions for each one so the resulting curve passes through all the points with continuous (no visible corner) curvature — similar to a Catmull-Rom-style spline. Without calling it, connecting the ten points directly would produce a jagged, faceted polygon instead of a smooth organic outline.

On every frame, each point's position is subtracted from an eased mouse position to get a vector pointing from that point toward the cursor, and its length gives the distance. Points within 220 pixels get moved along that vector by an amount that shrinks linearly with distance (closer points move more), which is why only the part of the blob nearest the cursor visibly stretches rather than the whole shape shifting.

mouse.add(targetMouse.subtract(mouse).multiply(0.08)) moves the tracked position only 8% of the way toward the real cursor each frame, so fast mouse movements produce a smooth trailing pull rather than the blob snapping instantly to match cursor position. That's the same easing technique used for smooth-following cursors and camera-follow effects generally.

If all ten points used the same sine wave, the whole blob would pulse in and out uniformly like a breathing circle rather than looking organic. Giving each point its own random phase offset and slightly different speed means they reach their wobble peaks and troughs at different times, producing the uneven, fluid motion that reads as an organic shape rather than a synchronized pulse.