Washing Line Hero
Move your pointer across the cloth. It dents under the cursor and recovers. Press and pull upward: the corner lifts toward you, flips over the line, and drops back when you let go. No video, no sprites — 357 particles, three constraint families, one fixed timestep.
Hover first, then drag the cloth upward until it flips over the line. “Physics & Poster” opens wind, stiffness, poster presets and the static fallback.
What you are feeling
Separate the effect into its parts. Each one is a number you can change.
- Dent
- Hover pushes nearby vertices away from the viewer on a Gaussian falloff, so the cotton reads as soft rather than painted. Move quickly and the dimple drags a short wake behind the pointer.
- Flip
- A drag also lifts the grabbed patch toward the camera. Once it crosses the rope, a thin collision plane keeps the cloth on the far side, so a corner can be thrown over the line instead of pushed through it.
- Return
- Release and gravity plus damping take over. Structural, shear and bending constraints are solved seven times per 120 Hz step, so the body of the cloth holds while the free corner swings and settles.
The prompt
Written to reproduce the behaviour, not just the look. Paste it into Claude Code, Cursor or v0.
You are a front-end engineer with a feel for cloth. Build a single HTML page whose whole job is one sensation: a cotton poster hanging from a washing line that can be touched, lifted and flipped. Every number below exists to make the cloth read as fabric, not as a deformed rectangle. [The scene] - Full-viewport hero, no scroll. Sky is a three-stop vertical gradient. Morning: #9ec9ee → #cde5f7 → #f2f6f9. Golden hour: #d99b78 → #f3cdb1 → #faf1e4. Blue hour: #0f1c38 → #1f3a63 → #4a668a. Four soft radial cloud blooms drift across it at different speeds, drawn as ellipses with a transparent outer stop; no blur filter. - A single rope crosses the viewport as a quadratic curve: left end at y = lineY − 26, right end at y = lineY − 18, control point at (52vw, lineY + 19). Draw a 3.5px shadow 3px lower, a 2.6px braided line, and a 0.9px sunlit highlight 0.8px above. - Two wooden clothespins clamp the top edge at 15% and 85% of the cloth width: a rounded body 12×38 with a three-stop wood gradient, a top notch, and a 4px metal spring band. - Left editorial column, max 36rem: mono eyebrow, serif headline clamp(2.25rem, 5.2vw, 3.5rem) at 1.06 line-height and −0.02em tracking, one paragraph, three pill buttons (Copy prompt, Gust, Reset), and a mono telemetry row that reports the fixed step, grid size and current gesture. [The cloth] - A 17 × 21 particle grid (357 particles, 16 × 20 segments) forms a 3:4 poster. Size it as min(max(27vw, 270px), 380px) wide on desktop and 66vw capped at 260px on mobile. On desktop centre it at 69vw; on mobile centre it horizontally at 48vh or lower. - Pins are row 0, columns 2 and 15. Give the top edge a catenary droop of up to 10px, and each particle an initial z of 4px × sin(c × 0.5 + r × 0.3) so the first frame already catches light. - Constraint families: structural (horizontal and vertical) at stiffness 1.0; shear (both diagonals) at 0.72; bending (two steps away) at 0.36. Solve all of them seven times per step by default, adjustable 3–12 from a slider. With these numbers the total is 1,954 constraints. [Physics] - Verlet integration at a fixed 120 Hz (dt = 1/120). Damping 0.992, gravity 980 px/s². Use an accumulator; clamp the incoming frame delta to 50 ms. - Wind is a time-varying vector: base 0.45, modulated by sin(t × 1.45) × 0.5 + sin(t × 3.1) × 0.25 + 0.65, with x = 260 × wind, y = sin(t × 2.2) × 45 × wind, z = (cos(t × 1.9) × 0.6 + 0.45) × 240 × wind. - Apply wind per triangle: normalise the triangle normal, multiply by the dot product of normal and wind, scale by 0.33, and add the same force to all three vertices. Add a per-triangle flutter of 0.75 + 0.35 × sin(t × 4.2 + u × 6 + v × 4) so the surface never moves as one sheet. - Clamp z to −260…280. [Touch] - Hover: for every unpinned particle within 74px of the pointer, add +Z force 180 × exp(−d² / (2 × 30²)), plus pointer velocity × 36 on x and y. This is the dent. - Pointer down: pick the nearest unpinned particle within 78px. Grab every unpinned particle within 56px of it, weighting each by cos((d / 56) × π/2)². Store each particle's offset from the pointer. - Drag: move grabbed particles 42% of the way toward the pointer plus 0.72 × their stored offset. Lift z toward −135 × lift − 35, where lift = clamp((centreY + 0.55 × clothH − pointerY) / (0.75 × clothH), 0, 1.3). This is what lets a corner flip over the rope. - Collision: after each solver iteration, any particle within 10px of the line and within 12px of z = 0 is snapped to z = ±12, staying on the side it came from. - On release, clear the grab and let gravity and damping settle the cloth. The rope itself is a damped spring: stiffness 90, damping 7.5, driven by the vertical pull of the hand. [The poster] - Draw the poster once into a 540 × 720 offscreen canvas, then map it onto the cloth triangle by triangle with an affine transform. Expand each clip triangle 0.65px from its centroid to hide seams. - Presets: an editorial Swiss poster (cobalt-to-sky block, orange sun, cream wave, serif “Touchable Physics.”); a Mediterranean linen (terracotta field, amber sun, navy arch, “Atelier Vento”); and a DeepSeek craft edition (dark panel, cyan orb, “Zero Slop. Real Feel.”). Add a cotton weave: 1px lines every 3px in both directions at 4.5–7% alpha, plus a dashed stitched hem 14px in from the edge. - When a triangle faces away from the camera, draw the mirrored back texture at 22% alpha so the poster reads as ink bleeding through cotton. - Light the cloth with a Lambert term against a per-sky light direction. Below 0.55, darken toward the sky's shadow colour by up to 42%; above, lift toward warm white by up to 20%. - Painter-sort triangles by average z. Draw the rope first, then cloth, then the two pegs. [Config, fallback and output] - Put eyebrow, headline, subtitle, sky theme, poster preset, wind, stiffness, gravity and damping into one hero.json object. The visible controls and the JSON editor both edit that object; applying redraws the poster and re-reads physics on the next step. - Static fallback: render the poster into an overlay and stop the animation loop. Enter it automatically under prefers-reduced-motion, and expose a visible Static / Live toggle so it can be inspected. - Cap devicePixelRatio at 2. Clamp frame delta to 50 ms. Never allocate per frame: reuse the particle, constraint and force arrays. - One complete HTML5 file. No libraries, no external images, no analytics. Write noindex, nofollow in head. Tailwind may be compiled ahead of time; do not ship the CDN build.
Sky morning: #9ec9ee → #cde5f7 → #f2f6f9 Sky golden: #d99b78 → #f3cdb1 → #faf1e4 Sky blue hour: #0f1c38 → #1f3a63 → #4a668a Rope: #5d4b3a · highlight #8a725a · shadow rgba(15,23,42,.14) Poster: 540×720 canvas · cotton #f6f2e9 · ink #18181b Swiss preset: #1d4ed8 → #0ea5e9 · sun #f97316 Mediterranean: #e76f51 · #f4a261 · #264653 DeepSeek: #101828 · #38bdf8 · #e2e8f0 Cloth: 17×21 particles · pins at columns 2 and 15 · 3:4 Constraints: structural 1.0 · shear 0.72 · bend 0.36 · 7 iterations Physics: 120 Hz fixed step · gravity 980 · damping 0.992 · wind 0.45 Hover: radius 74 · sigma 30 · force 180 Grab: radius 78 · patch 56 · lift −135 · rest −35 Type: serif headline clamp(2.25rem,5.2vw,3.5rem)/1.06/−0.02em · mono 11px telemetry Radii: pills 9999px · panels 16px · poster 2px
- One HTML file plus compiled Tailwind; about 650 lines of JavaScript - Canvas 2D only — no WebGL, no shader, no external image - 357 particles and 1,954 constraints, solved 3–12 times per 120 Hz step - Fixed-step accumulator with a 50 ms frame-delta clamp - Procedural cotton poster drawn into an offscreen 540 × 720 canvas - hero.json as the single source of truth for copy, sky and physics - Pointer Events; no gesture library
Rules we imposed
- 01 One gesture: hover and drag. No pinch, no rotate, no scroll hijack.
- 02 The poster is the only content. No video, no sprite sheet, no shader, no external image.
- 03 Physics runs on a fixed 120 Hz accumulator. Rendering may drop frames; the cloth does not slow down.
- 04 The cotton, the ink and the backface bleed are drawn into offscreen canvases. Nothing is loaded.
- 05 One hero.json object drives copy, sky, poster and physics. The controls edit that object, not hidden state.
- 06 The fallback is a designed poster, not a blank frame or an apology.
Performance fallback
The effect degrades on purpose. A material that only works on a fast laptop is a demo, not a design.
- prefers-reduced-motion starts in static mode: the poster is generated, but the simulation loop never starts.
- The visible “Static” toggle stops the rAF loop and shows the poster at any time; “Live” restarts it.
- Device pixel ratio is capped at 2, and frame delta is clamped to 50 ms so a backgrounded tab cannot flood the accumulator.
- Cost is bounded by construction: 357 particles, 1,954 constraints, and 3–12 solver iterations chosen by the stiffness slider.
prefers-reduced-motion → static poster · Static toggle stops the rAF loop · DPR ≤ 2 · frame delta ≤ 50 ms · 357 particles / 1,954 constraints
What it is not
- Not a garment simulator. There is no self-collision, friction, tearing or cloth-to-cloth contact; the grid is a hero toy.
- Not a fabric scan. The poster and the weave are procedural canvas drawings, not photographic material.
- Not benchmarked on a device lab. Performance is bounded by design, not measured per handset.